自己的原型创建出错

时间:2014-04-10 07:29:19

标签: java spring maven

我使用链接

创建了我自己的原型

http://maven.apache.org/guides/mini/guide-creating-archetypes.html

这是我的SpringHibernateArcheType \ pom.xml for archetype

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>SpringHibernateArchetype</groupId>
<artifactId>SpringHibernateArcheType</artifactId>
<version>1.0-SNAPSHOT</version>
<name>Archetype - SpringHibernateArcheType</name>
<url>http://maven.apache.org</url>
</project>

我的SpringHibernateArcheType \ src \ main \ resources \ META-INF \ maven \ archetype.xml

<archetype
xmlns="http://maven.apache.org/plugins/maven-archetype-plugin/archetype/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-archetype-plugin/archetype/1.0.0 http://maven.apache.org/xsd/archetype-1.0.0.xsd">
<id>SpringHibernateArcheType</id>
<sources>
    <source>src/main/java/App.java</source>
</sources>
<resources>
    <resource>src/main/webapp/WEB-INF/web.xml</resource>
    <resource>src/main/webapp/index.jsp</resource>

</resources>
<testSources>
    <source>src/test/java/AppTest.java</source>
</testSources>
</archetype>

代码工作正常,我想再添加一个配置,即Spring MVC应用程序的应用程序上下文,它是servlet-name-servlet.xml格式。大多数情况下,我选择artifactId作为我的DispatcherServlet名称,那么如何添加名为

的上下文文件

src/main/webapp/WEB-INF/{artifactId}-servlet.xml在我的原型中。

我尝试添加代码

<resource>src/main/webapp/WEB-INF/${artifactId}-servlet.xml</resource>

但它给我带来了错误

合并速度模板时出错

如何解决此问题?

这是堆栈跟踪,

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2.2:generate (default-cli) on project standalone-pom: Error merging velocity templates -> [
Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2.2:generate (default-cli) on project stand
alone-pom: Error merging velocity templates
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:317)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:152)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:555)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoFailureException: Error merging velocity templates
        at org.apache.maven.archetype.mojos.CreateProjectFromArchetypeMojo.execute(CreateProjectFromArchetypeMojo.java:211)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:106)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
        ... 19 more

0 个答案:

没有答案