【问题标题】:Tomcat overrides application.properties file in eclipseTomcat 覆盖 Eclipse 中的 application.properties 文件
【发布时间】:2021-11-05 07:45:12
【问题描述】:

我正在尝试在外部 tomcat 上运行我的骆驼应用程序。我的项目中有 2 个 application.properties 文件,一个在 src/main/resources 下,另一个在 src/test/resources 下。当我使用 maven install 命令创建 war 文件时,它使用 src/main/resources 中的 application.properties 文件(这是必需的)但是当我在 eclipse 中使用 tomcat 启动应用程序时,它使用的是 src/test 中的 application.properties 文件/资源。我还从 Eclipse 中删除了 src/test/resources 的类路径条目,但没有运气。我不太确定它是如何从 src/test/resources 中选择 application.properties 文件的。

当我删除 src/test/resources 下的 application.properties 文件时,它可以正常工作,即它会选择 src/main/resources 下的 application.properties 文件。

我们正在使用:

  • Oracle JDK 8
  • 春季 4.3.11.RELEASE
  • Tomcat 8.5
  • 骆驼 2.20.2
  • ActiveMQ 5.15.0
  • Maven 构建工具

提前致谢。

【问题讨论】:

  • 我重新创建了相同的场景。但是在我的情况下,当我从终端从 eclipse 和 mvn 构建项目时,我从 main 获取 application.properties。从两个地方构建时检查哪个文件包含在 target/calsses 目录中

标签: java tomcat apache-camel classpath application.properties


【解决方案1】:

当 Eclipse 将项目部署到服务器时,重要的设置是 “部署程序集”,而不是 “Java 构建路径”。如果从部署程序集中删除 src/test/resources 文件夹,则不会复制其中包含的文件。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-01-24
    • 2014-04-18
    • 1970-01-01
    • 2013-05-07
    • 2019-07-17
    • 2020-11-09
    • 1970-01-01
    相关资源
    最近更新 更多