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?

Aniket Thakur
  • 66,731
  • 38
  • 279
  • 289
  • 1
    I think `cospring-demo` is not a valid package name (contains hyphen) try using `cospring` in your class `App`. – Katona Jan 18 '14 at 10:58
  • You really shouldn't use `mvn idea:idea`. It is obsolete: http://stackoverflow.com/a/11903127/1350762. – maba Jan 18 '14 at 14:39

1 Answers1

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

Community
  • 1
  • 1
MariuszS
  • 30,646
  • 12
  • 114
  • 155