簡體   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