tomcat7-maven-plugin启动读取占位符失败

生活因我绚丽 2018-03-23 02:49:00
由于不同环境需要配置不同的配置文件,所以我采用maven-war-plugin插件来解决这个问题,其中使用了占位符。打包是没有问题,可以分环境做打包。
但是本地运行项目我们是采用tomcat7-maven-plugin启动的,此时控制台会在打包操作中报占位符错误。
请大侠们帮忙提供一下思路,注:项目不能启动热部署tomcat插件启动,只能依赖tomcat-maven-plugin.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<webResources>
<resource>
<!-- this is relative to the pom.xml directory -->
<directory>src/main/ui</directory>
<filtering>true</filtering>
</resource>
<resource>
<directory>src/main/ui/${package.environment}</directory>
<targetPath>/</targetPath>
<filtering>true</filtering>
</resource>
</webResources>
</configuration>
</plugin>

报错信息:
[INFO] Copying webapp webResources [E:\workspace\hxxyz-source\src/main/ui] to [E:\workspace\hxxyz-source\target\hxxyz]
[INFO] Copying webapp webResources [E:\workspace\hxxyz-source\src/main/ui/${package.environment}] to [E:\workspace\hxxyz-source\target\hxxyz]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 07:55 min
[INFO] Finished at: 2018-03-23T14:41:49+08:00
[INFO] Final Memory: 178M/504M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.1.1:war (default-war) on project his-mvn: Execution default-war of goal org.apache.maven.plugins:maven-war-plugin:2.1.1:war failed: basedir E:\workspace\hxxyz-source\src\main\ui\${package.environment} does not exist -> [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/PluginExecutionException
...全文
570 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
生活因我绚丽 2018-04-09
  • 打赏
  • 举报
回复
可以在启动tomcat插件时,右击选择新建,在弹出的窗口中查看环境变量是否赋值成功,如果已赋值,那么启动就没有问题了。 这个问题出现在启动tomcat动作有问题。
CrazyCoder1992 2018-04-02
  • 打赏
  • 举报
回复
在jvm启动参数中添加变量
生活因我绚丽 2018-03-23
  • 打赏
  • 举报
回复
<profile> <id>vir</id> <properties> <package.environment>vir</package.environment> </profile> 变量可以在这里定义,然后idea中会展示出定义的profile,勾选上maven打包就好了。 但是tomcat maven插件不知道怎么搞
maradona1984 2018-03-23
  • 打赏
  • 举报
回复
${package.environment}这个应该是从命令取吧,启动tomcat的命令那也得加上这个运行变量吧

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧