简体   繁体   English

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

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

I have an own .jar file with some configuration about OAuth2 and Spring security Server. 我有一个自己的.jar文件,其中带有有关OAuth2和Spring安全服务器的一些配置。 Now I want to edit file .xml in it to suitable with my project (like url, value, name). 现在,我想在其中编辑文件.xml以适合我的项目(例如url,值,名称)。 So do we have any way to do it. 那么我们有什么办法做到这一点。

Thanks. 谢谢。

An option is to externalize your properties into a property file, web container (tomcat, jboss)enviroment variables or SO enviroment variables. 一种选择是将属性外部化为属性文件,Web容器(tomcat,jboss)环境变量或SO环境变量。

Then you need to tell Spring where your properties are located 然后,您需要告诉Spring您的属性在哪里

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

Here there are some tutorials 这里有一些教程

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

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

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

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