I have a method that I don't want loaded in my Local Spring profile. The method is
@Profile("prod")
@Scheduled(initialDelay = 1000, fixedDelay = 21600000)
public void updateHackalistHackathonData() {
...
}
I have created an application.properties'
, application-local.properties'
and application-prod.properties
file in the same location src/java/resources
. In application.properties
, I mentioned spring.profiles.active=local
.
However, this method which is a scheduled one still goes into execution. How do I stop this?
You need to add @Profile("prod")
annotation on class (bean) definition not method itself. Eg:
@Component
@Profile("prod")
public class HackatonScheduler{
@Scheduled(initialDelay = 1000, fixedDelay = 21600000)
public void updateHackalistHackathonData() {
...
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.