2016-05-04 10 views
0

So lesen Sie diese (fixedRate = 12000) 12000 Formulareigenschaftsdatei im Frühjahr.So lesen Sie Schlüssel - Wert - Paar aus der Eigenschaftendatei mithilfe von Anmerkungen

@Scheduled(fixedRate=120000) 
public void tlogZipping() throws MposWSException { 
    LOGGER.info("Started tlog Zipping Job............. {}" + new Date()); 
    try { 
     //...................... 
    } catch (Exception e) { 
     LOGGER.error("FAIL TO CREATE RECEIPT ZIP FILE: {}",e); 
     throw new MposWSException(MposWSErrorCodes.FAIL_TO_CREATE_RECEIPT_ZIP_FILE, e); 
    } 
    LOGGER.info("Stopped tlog Zipping Job............."); 
} 
+0

gibt es keine solche Datei, was ich konnte, um Ihren Code zu sehen ?? @Dipesh –

+0

Mein Dateiname ist MyProperty.properties und es enthält: TLOG_ZIPPING_TIME_INTERVEL_IN_MINUTES = 1200000 –

+0

ist dies ein kommentierte Schlüssel wie '@ TLOG_ZIPPING_TIME_INTERVEL_IN_MINUTES' oder einfache Schlüssel wie' TLOG_ZIPPING_TIME_INTERVEL_IN_MINUTES' –

Antwort

0

Sie können Ihre Properties-Datei in den Ordner hinzufügen, wo Ihr classes sind vorhanden. und dann diesen Code versuchen.

@PropertySource("classpath:config.properties") //set your Properties file source. 
public class YourClass{ 

    //1.2.3.4 
    @Value("${TLOG_ZIPPING_TIME_INTERVEL_IN_MINUTES }") //read your Property Key 
    private String IntervalTimeInMin; //Store in this Variable. 

    //hello 
    @Value("${anotherProperty}") //readd another Property Key 
    private String anotherProperty; //Store in this Variable. 

Weitere assistence können Sie diese finden Link Here

+0

Danke Vikrant, aber wenn es gut ist, können wir @Scheduled (fixedRate = 120000) diese "120000" mit einem beliebigen ganzzahligen Wert in der Klasse ändern. Also kann ich diesen int-Wert im Konstruktor initialisieren. –

Verwandte Themen