johanvs
johanvs

Reputation: 4393

Get the domain name outside a Spring controller

How can I get the domain name of my Spring app outside a Controller?

I want to create a link to a Controller in a @Scheduled method, but here I don't have a Request object to get the domain name.

Upvotes: 0

Views: 666

Answers (1)

Periklis Douvitsas
Periklis Douvitsas

Reputation: 2491

I do no think that you can get it in a @Scheduled method. This would be part of your configuration. ie you can set a value in the resources->xxxxx.properties file

domain = mydomain

and then in your service class you can get it like this

@Value("${domain}")
private String domain;

Hope this helps

Upvotes: 1

Related Questions