Gangmax Blog

Create Maven Spring MVC Project Skeleton

A SpringMVC Maven arachetype is defined here. Run the following command to use it:

1
2
3
4
5
6
7
8
mvn archetype:generate \
-DarchetypeGroupId=pl.codeleak \
-DarchetypeArtifactId=spring-mvc-quickstart \
-DarchetypeVersion=1.0.1 \
-DgroupId=my.groupid \
-DartifactId=my-artifactId \
-Dversion=version \
-DarchetypeRepository=http://kolorobot.github.io/spring-mvc-quickstart-archetype

However I get the following error:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> maven-archetype-plugin:3.0.1:generate (default-cli) > generate-sources @ standalone-pom >>>
[INFO]
[INFO] <<< maven-archetype-plugin:3.0.1:generate (default-cli) < generate-sources @ standalone-pom <<<
[INFO]
[INFO] --- maven-archetype-plugin:3.0.1:generate (default-cli) @ standalone-pom ---
[INFO] Generating project in Interactive mode
[WARNING] Archetype not found in any catalog. Falling back to central repository.
[WARNING] Add a repsoitory with id 'archetype' in your settings.xml if archetype's repository is elsewhere.
[WARNING] The POM for pl.codeleak:spring-mvc-quickstart:jar:1.0.1 is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.096 s
[INFO] Finished at: 2017-07-20T19:10:14+08:00
[INFO] Final Memory: 15M/140M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:3.0.1:generate (default-cli) on project standalone-pom: The desired archetype does not exist (pl.codeleak:spring-mvc-quickstart:1.0.1) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

The problem is that Maven cannot find the “pl.codeleak:spring-mvc-quickstart:jar:1.0.1” artifact. Add the following content in the “~/.m2/settings.xml” file to fix the issue:

~/.m2/settings.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
...
<profiles>
<profile>
<repositories>
...
<repository>
<id>kolorobot</id>
<name>Kolorobot Repository</name>
<url>http://kolorobot.github.io/spring-mvc-quickstart-archetype</url>
</repository>
</repositories>
...
</profile>
</profiles>
...

Run the Maven command again and this time it works.

Comments