2

I am new to maven and trying to run simple spring demo. I am using Intellij IDEA as my IDE. I am following tutorial provided here.

So i ran

mvn archetype:generate -DgroupId=SpringDemo -DartifactId=SpringExamples -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false 

and then did

mvn idea:idea 

It generated all .ipr,.iws etc file. Then I simply did open from IDEA and selected the .ipr file. It detected it as IDEA project and opened it but it gives me following error

Package name 'cospring' does not correspond to the file path 'cospring-demo' 

App class is

package cospring-demo; /** * Hello world! * */ public class App { public static void main( String[] args ) { System.out.println( "Hello World!" ); } } 

What is the issue? Any work around?

2
  • 1
    I think cospring-demo is not a valid package name (contains hyphen) try using cospring in your class App. Commented Jan 18, 2014 at 10:58
  • You really shouldn't use mvn idea:idea. It is obsolete: stackoverflow.com/a/11903127/1350762. Commented Jan 18, 2014 at 14:39

1 Answer 1

1

This is good explanation

Maven groupIds prefer dashes ("-"), but the Java compiler forbids dashes in package names. Yet the archetype plugin simply spits out what the user gave as the groupId. ARCHETYPE-216

Simply avoid using - in groupId generated from archetype.

If the domain name contains a hyphen, or any other special character not allowed in an identifier (§3.8), convert it into an underscore. JLS

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.