1

当我使用 maven2 运行我的工作时,一切正常,但使用 maven 3 (3.0.3) 我遇到了错误。请注意,我没有在任何地方定义“warSourceExcludes”属性

message : Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.0:war (default-war) on project specific-admin: Unable to parse configuration of mojo org.apache.maven.plugins:maven-war-plugin:2.0:war: When configuring a basic element the configuration cannot contain any child elements. Configuration element 'warSourceExcludes'.
cause : Unable to parse configuration of mojo org.apache.maven.plugins:maven-war-plugin:2.0:war: When configuring a basic element the configuration cannot contain any child elements. Configuration element 'warSourceExcludes'.
Stack trace : 
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.0:war (default-war) on project specific-admin: Unable to parse configuration of mojo org.apache.maven.plugins:maven-war-plugin:2.0:war: When configuring a basic element the configuration cannot contain any child elements. Configuration element 'warSourceExcludes'.
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:221)
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:319)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
at org.jvnet.hudson.maven3.launcher.Maven3Launcher.main(Maven3Launcher.java:79)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchStandard(Launcher.java:329)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:239)
at org.jvnet.hudson.maven3.agent.Maven3Main.launch(Maven3Main.java:158)
at hudson.maven.Maven3Builder.call(Maven3Builder.java:100)
at hudson.maven.Maven3Builder.call(Maven3Builder.java:66)
at hudson.remoting.UserRequest.perform(UserRequest.java:118)
at hudson.remoting.UserRequest.perform(UserRequest.java:48)
at hudson.remoting.Request$2.run(Request.java:326)
at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)

Caused by: org.apache.maven.plugin.PluginConfigurationException: Unable to parse configuration of mojo org.apache.maven.plugins:maven-war-plugin:2.0:war: When configuring a basic element the configuration cannot contain any child elements. Configuration element 'warSourceExcludes'.
at org.apache.maven.plugin.internal.DefaultMavenPluginManager.populatePluginFields(DefaultMavenPluginManager.java:597)
at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getConfiguredMojo(DefaultMavenPluginManager.java:529)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:92)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
... 27 more
Caused by: org.codehaus.plexus.component.configurator.ComponentConfigurationException: When configuring a basic element the configuration cannot contain any child elements. Configuration element 'warSourceExcludes'.
at org.codehaus.plexus.component.configurator.converters.basic.AbstractBasicConverter.fromConfiguration(AbstractBasicConverter.java:122)
at org.codehaus.plexus.component.configurator.converters.ComponentValueSetter.configure(ComponentValueSetter.java:331)
at org.codehaus.plexus.component.configurator.converters.composite.ObjectWithFieldsConverter.processConfiguration(ObjectWithFieldsConverter.java:151)
at org.codehaus.plexus.component.configurator.BasicComponentConfigurator.configureComponent(BasicComponentConfigurator.java:56)
at org.apache.maven.plugin.internal.DefaultMavenPluginManager.populatePluginFields(DefaultMavenPluginManager.java:567)
... 30 more

我的战争插件配置如下。specific-admin 是 common-admin 的子项目

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-war-plugin</artifactId>
  <version>2.0</version>
  <configuration>
    <warName>specific-admin</warName>
  </configuration>
</plugin>
4

1 回答 1

5

我也遇到了同样的错误,但使用以下更改解决了:

目前是:

<plugin>
     <groupId>org.apache.maven.plugins</groupId>
     <artifactId>maven-war-plugin</artifactId>
     <configuration>
       <warName>${project.parent.artifactId}-admin</warName>
       <includes>
          <include>*.xsd</include>
          <include>*.xml</include>
          <include>*.xsl</include>
          <include>*.txt</include>
          <include>*.properties</include>
          <include>META-INF/.</include>
       </includes>
     </configuration>
</plugin>

代替

  <includes><include>....</includes>

任何一个

    <warSourceIncludes>*.xsd, *.xml, *.xsl, *.txt, *.properties, META-INF/., WEB-INF/web.xml</warSourceIncludes>    

或者

    <includes>*.xsd, *.xml, *.xsl, *.txt, *.properties, META-INF/., WEB-INF/web.xml</includes>  
于 2014-02-18T11:55:09.900 回答