简体   繁体   English

如何在 spring web 应用程序中找到 application.properties,虽然位置被提及为 classpath:/application.properties 但文件丢失?

[英]How to find the application.properties in spring web app, while location is mentioned as classpath:/application.properties but file is missing?

This project was not touched for 2 years.这个项目有2年没有动过。 Following code is written in spring-security.xml以下代码写在 spring-security.xml

  <b:bean id="mappings" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <b:property name="location">
            <b:value>classpath:/application.properties</b:value>
        </b:property>
  </b:bean> 
  <b:bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
        destroy-method="close">
        <b:property name="driverClassName" value="com.mysql.jdbc.Driver" /> 
        <b:property name="url" value="${SPRING_DATASOURCE_URL}" />
        <b:property name="username" value="${SPRING_DATASOURCE_USERNAME}" />
        <b:property name="password" value="${SPRING_DATASOURCE_PASSWORD}" />
  </b:bean>

I checked src/main/resources , entire code base, entire system (macOS level search) and I couldn't find application.properties.我检查了src/main/resources 、整个代码库、整个系统(macOS 级别搜索),但找不到 application.properties。

What I know for sure is, when the application is run locally(in my laptop) it uses SPRING_DATASOURCE_URL , USERNAME and PASSWORD to connect to remote AWS db.我确定的是,当应用程序在本地(在我的笔记本电脑中)运行时,它使用SPRING_DATASOURCE_URLUSERNAMEPASSWORD连接到远程 AWS db。

Question: How can I debug and find out the location of the file?问题:如何调试并找出文件的位置?

PS: I did try file search etc. for search string 'SPRING_DATASOURCE_URL' PS:我确实尝试了文件搜索等搜索字符串“SPRING_DATASOURCE_URL”

Moving my comment to answer.移动我的评论来回答。

Possibly the property file is in the server folder where the web app is deployed.属性文件可能位于部署 web 应用程序的服务器文件夹中。 Further investigation can be done by enabling Spring debug logs.可以通过启用 Spring 调试日志来进行进一步调查。

How can I debug and find out the location of the file?如何调试并找出文件的位置?

Set breakpoints in all public methods of PropertyPlaceholderConfigurer and its parent classes.在 PropertyPlaceholderConfigurer 及其父类的所有公共方法中设置断点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 访问spring启动应用程序.properties中提到的配置文件,在创建.jar后用于App引擎部署 - Access configuration file mentioned in spring boot application.properties after creating the .jar for App engine deployment Spring-将Web表单绑定到application.properties文件 - Spring - Binding web form to application.properties file 如何在 spring 应用程序中动态修改 application.properties 文件? - How to Modify application.properties file dynamically in spring application? Spring application.properties文件中的布尔值? - boolean values in Spring application.properties file? Spring boot application.properties 文件读取 - Spring boot application.properties file reading Spring 引导无法识别 application.properties 文件 - Spring Boot not recognizing application.properties file 如何从 spring 引导应用程序之外的位置读取 application.properties 文件 - How to read the application.properties file from a location outside the spring boot application 如何找到 application.properties 的“spring.datasource.url=”? - How to find "spring.datasource.url=" for application.properties? 如何阅读Spring Boot application.properties? - How to read Spring Boot application.properties? 如何在 Spring 中更改 Application.properties 的值 - how to change values of Application.properties in Spring
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM