gpt4 book ai didi

Java Spring : How to specify resource path's correctly in application. 属性?

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:23:34 28 4
gpt4 key购买 nike

我正在开发一个 Spring 项目,前开发人员在 application.properties 中使用了一些完整的资源访问路径,例如:

java.resource=/full/path/src/main/resources/somefile
webapp.resource=/full/path/src/main/webapp/resources/somefile

我认为链接到源文件夹不是什么好习惯,对吧?

正如我所见,src/main/resources/ 中的文件被提取到 Tomcat 的 webapps/projekt-1.0.0/WEB-INF/classes 目录和来自 src/main/webapp/resources/ 的文件被提取到 webapps/projekt-1.0 .0/资源

如何以正确的方式执行此操作,以便我不需要单独的 .properties 文件用于开发/暂存 等?

最佳答案

根据您的目录结构,我可以假设您正在使用 Maven 吗?如果那是真的,那么你的陈述是正确的。 Maven结构目录自动扫描src/main/resources路径作为构建路径,所以你只需要将你的properties文件放在那里,并在你的applicationContext.xml上调用该文件.

<!-- read value from .properties file -->
<context:property-placeholder location="classpath:<your_file_name>.properties"/>

关于Java Spring : How to specify resource path's correctly in application. 属性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48934448/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com