繁体   English   中英

在Java中使用xml或Properties文件编辑Jar文件

[英]Edit Jar file with xml or properties file in Java

我有一个自己的.jar文件,其中带有有关OAuth2和Spring安全服务器的一些配置。 现在,我想在其中编辑文件.xml以适合我的项目(例如url,值,名称)。 那么我们有什么办法做到这一点。

谢谢。

一种选择是将属性外部化为属性文件,Web容器(tomcat,jboss)环境变量或SO环境变量。

然后,您需要告诉Spring您的属性在哪里

@Configuration
@PropertySource("file:${app.home}/app.properties")
public class AppConfig {
    @Autowired
    Environment env;
}

这里有一些教程

https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html

http://www.mkyong.com/spring/spring-propertysources-example/

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM