We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
方式二:如果项目中不存在以上文件,且不想单独新增,也可以在项目启动时调用 ConfigUtil.bundleNames("xxx") 来指定要读取的文件,这时只会从用户给定的文件中查找。
ConfigUtil.bundleNames只能指定项目路径classpath下的某个属性文件吗?如果我将来要发布到生产环境,怎么读取linux服务器上分离出来的属性文件呢? 或者是否支持spring boot的application.yml文件,在yml文件里配置呢?
The text was updated successfully, but these errors were encountered:
@wulinjie122
spring boot 使用时仅支持 application.properties,不支持 application.yml。
application.properties
application.yml
其实不同环境的配置可以通过 maven 的 profile 功能来实现。
<profiles> <profile> <id>dev</id> <properties> <env>dev</env> </properties> </profile> <profile> <id>prod</id> <properties> <env>prod</env> </properties> </profile> </profiles>
在 src/main/resources/encrypt 下新建 encrypt.properties、encrypt-dev.properties、encrypt-prod.properties 三个文件
encrypt.properties
encrypt-dev.properties
encrypt-prod.properties
在 pom.xml 的 resources 标签下声明 resource 和 filter 即可
<build> <resources> <resource> <directory>src/main/resources/encrypt</directory> <filtering>true</filtering> <includes> <include>encrypt.properties</include> </includes> </resource> </resources> <filters> <filter>src/main/resources/encrypt/encrypt-${env}.properties</filter> </filters> </build>
Sorry, something went wrong.
好的,谢谢,我试一下。
No branches or pull requests
ConfigUtil.bundleNames只能指定项目路径classpath下的某个属性文件吗?如果我将来要发布到生产环境,怎么读取linux服务器上分离出来的属性文件呢?
或者是否支持spring boot的application.yml文件,在yml文件里配置呢?
The text was updated successfully, but these errors were encountered: