के बाहर गुण फ़ाइल को कैसे पढ़ा जाए, वहां 2 फ़ोल्डर्स, lib और conf हैं। सभी गुण फ़ाइलों को conf फ़ोल्डर में रखा जाता है, और जार lib foulder में रखा जाता है।स्प्रिंग बूट मेरे लक्षित फ़ोल्डर में जार
बूट वसंत के पिछले है, हम spring.xml में विन्यास निम्न का उपयोग @value
<context:property-placeholder location="classpath*:*.properties"/>
और की तरह जावा कोड में उपयोग करने के लिए:
@Value("${name}")
private String name;
लेकिन वसंत बूट में, मैं नहीं जावा कोड में ऐसा करने के बारे में जानें।
मैं निम्नलिखित की कोशिश की है, लेकिन काम नहीं
@Configuration
@PropertySource(value = "classpath:aaa.properties")
public class AppConfig {
@Bean
public PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
return new PropertySourcesPlaceholderConfigurer();
}
}
धन्यवाद, इस प्रस्ताव महान मूल्य –
क्या आप जानते हैं अगर मैं गुणा गुण फ़ाइलें, यह कैसे अलग कॉन्फ़िग कक्षा में पढ़ने के लिए? –
क्या आप कई बाहरी फाइलों का जिक्र कर रहे हैं? – Alberto