java - 获取值配置服务器Spring Boot

标签 java spring maven

我使用 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>

应用程序属性:

spring.application.name=letter-printing-eap-generator

bootstrap.yml:

spring.jmx.default-domain: letter-printing-eap-generator

最佳答案

@Service
public class SomeServiceServiceImpl implements SomeService{


    @Value("${letter-printing-eap-generator}")
    private String letterPrintingEapGenerator;

    //methods

}

关于java - 获取值配置服务器Spring Boot,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47808156/

相关文章:

Java-hibernate是否支持审核模式和历史记录支持?

maven - 将报告生成到时间戳文件夹时失败

java - 用log4j2将maven项目打包成jar

maven - 使用 ansible playbook 在 docker 容器内运行 mvn clean install

java - Java String REGEX 识别 DOI 的正确格式是什么

java - 拖动会禁用其他 MouseMotionListener

java - XML 布局 2 个 View 居中,1 个在顶部

java - 将 bean 添加到 Autowiring 列表

java - Spring MVC : Saving a string in servlet-context and accessing from java code

Spring批处理还是Spring boot异步方法执行?