Albertus Bobby
Albertus Bobby

Reputation: 75

get value config server spring boot

I use spring boot and jboss eap 6.4 for deploying application. in my pom.xml set config server. the file name is letter-printing-eap-generator.yml. this file contains value. how to get the data from this file? or can you give me the references? because I had find but no one match with my case.

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

Upvotes: 1

Views: 1700

Answers (2)

maruf571
maruf571

Reputation: 1945

@Service
public class SomeServiceServiceImpl implements SomeService{


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

    //methods

}

Upvotes: 1

Den B
Den B

Reputation: 921

In spring boot thereis annotation @Value You can use it to get values from you properties files. It works like this: @Value("${letter-printing-eap-generator}")

Upvotes: 1

Related Questions