我有maven项目,我希望能够将一些属性文件移动到输出的.war文件,以便spring中的属性占位符能够使用属性文件。
目前的目录结构是:
|- src
|- main
|- properties
|- dev
|- int
|- live
|- test
|- pom.xml
我希望能够获取src / properties / dev文件并将它们放在占位符的war文件中。但是目前我的pom中有以下配置部分。
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<webResources>
<resource>
<directory>src/properties/dev/</directory>
</resource>
</webResources>
</configuration>
</plugin>
然后我不断收到以下错误:
[INFO] ------------------------------------------------------------------------
[ERROR] FATAL ERROR
[INFO] ------------------------------------------------------------------------
[INFO] basedir src\properties\dev does not exist
[INFO] ------------------------------------------------------------------------
[INFO] Trace
java.lang.IllegalStateException: basedir src\properties\dev does not exist
at org.codehaus.plexus.util.DirectoryScanner.scan(DirectoryScanner.java:542)
at org.apache.maven.plugin.war.AbstractWarMojo.getWarFiles(AbstractWarMojo.java:824)
at org.apache.maven.plugin.war.AbstractWarMojo.copyResources(AbstractWarMojo.java:408)
at org.apache.maven.plugin.war.AbstractWarMojo.buildWebapp(AbstractWarMojo.java:518)
at org.apache.maven.plugin.war.AbstractWarMojo.buildExplodedWebapp(AbstractWarMojo.java:347)
at org.apache.maven.plugin.war.WarMojo.performPackaging(WarMojo.java:164)
at org.apache.maven.plugin.war.WarMojo.execute(WarMojo.java:130)
at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:483)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:678)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:540)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:519)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:371)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:332)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:181)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:356)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:137)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:41)
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.classworlds.Launcher.launchEnhanced(Launcher.java:315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
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 com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7 seconds
[INFO] Finished at: Tue Jan 18 10:02:17 GMT 2011
[INFO] Final Memory: 25M/62M
[INFO] ------------------------------------------------------------------------
我知道它存在,但似乎没有关于我为什么会收到此错误的信息,我的朋友建议我可能与不是源代码的属性相关文件夹,但我已经尝试添加codehaus插件,允许您添加新的源文件夹,这似乎没有帮助。
答案 0 :(得分:2)
我认为你有一个多项目构建。 Here是与此相关的问题,已在2.1-Alpha
中修复。
也许您应该尝试使用<version>2.1.1<version>
代替2.0.2