[英]Spring Boot @ConfigurationProperties with config server?
[英]get value config server spring boot
我使用spring boot和jboss eap 6.4來部署應用程序。 在我的pom.xml設置配置服務器中。 文件名是letter-printing-eap-generator.yml。 該文件包含值。 如何從該文件中獲取數據? 還是可以給我參考? 因為我找到了,但沒有一個與我的案子匹配。
pom.xml中:
<properties>
<config.server>http://10.170.49.103/configserver</config.server>
</properties>
<plugin>
<groupId>org.jboss.as.plugins</groupId>
<artifactId>jboss-as-maven-plugin</artifactId>
<version>7.9.Final</version>
<configuration>
<jbossHome>${jboss.home}</jbossHome>
<serverArgs>
<serverArg>-Dspring.profiles.active=${run.profiles}</serverArg>
<serverArg>-Dspring.cloud.config.uri=${config.server}</serverArg>
</serverArgs>
</configuration>
</plugin>
application.properties:
spring.application.name=letter-printing-eap-generator
bootstrap.yml:
spring.jmx.default-domain: letter-printing-eap-generator
在春季啟動中,有注釋@Value,您可以使用它從屬性文件中獲取值。 它的工作方式如下:@Value(“ $ {letter-printing-eap-generator}”)
@Service
public class SomeServiceServiceImpl implements SomeService{
@Value("${letter-printing-eap-generator}")
private String letterPrintingEapGenerator;
//methods
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.