2017-01-21 1 views
1

Ich habe eine Methode, die ich nicht in meinem Local Spring-Profil geladen werden soll. Das Verfahren istMethode lädt in Spring Boot, obwohl es nicht in Spring Boot Profil

@Profile("prod") 
@Scheduled(initialDelay = 1000, fixedDelay = 21600000) 
public void updateHackalistHackathonData() { 
... 
} 

ich geschaffen habe eine application.properties', application-local.properties' und application-prod.properties Datei in der gleichen Position src/java/resources. In application.properties erwähnte ich spring.profiles.active=local.

Diese Methode, die eine geplante ist, wird jedoch weiterhin ausgeführt. Wie höre ich damit auf?

+0

Könnten Sie Ihre PropertyPlaceholderConfigurer-Konfiguration (XML oder Annotation) und web.xml? –

Antwort

2

Sie müssen @Profile("prod") Annotation auf Klasse (Bean) Definition nicht Methode selbst hinzufügen. Zum Beispiel:

@Component 
@Profile("prod") 
public class HackatonScheduler{ 
    @Scheduled(initialDelay = 1000, fixedDelay = 21600000) 
    public void updateHackalistHackathonData() { 
     ... 
    } 
} 
+0

Das war es, danke! – bholagabbar