Spring instantiating object with @Value

Asked

Viewed 141 times

2

In my application.properties has the algumaCoisa=joao, and when I spin the java -jar nomedo.jar, it comes null, someone can explain to me why this happens and how I arrange?

@Component
class TesteClass{
    @Value("${algumaCoisa}")
    String nome

    String nomeDoValue
    String sobrenome

    TesteClass(info){

        this.nomeDoValue = nome
        this.sobrenome = info.sobrenome
    }
}

@Service
class AlgumService{
    //...
    for(i = 0; i < 3; i++){
        def objeto = new TesteClass(info)
        //...
    }
    //...
}

1 answer

1

Browser other questions tagged

You are not signed in. Login or sign up in order to post.