Git에서 application.properties 파일을 보관하고있는 개인 저장소를 작성했습니다.@ConfigurationProperties가 외부 특성 파일을 가져 오지 않습니다.
클라우드 설정 서버 ('my-config-server')를 만들고 git 저장소 URL을 사용했습니다.
Git 저장소를 사용하여 외부 속성 파일에 액세스해야하는 스프링 부트 응용 프로그램을 바인딩했습니다.
@javax.jws.WebService(
serviceName = "myService",
portName = "my_service",
targetNamespace = "urn://vdc.com/xmlmessaging/SD",
wsdlLocation = "classpath:myService.wsdl",
endpointInterface = "com.my.service.SDType")
@PropertySource("application.properties")
@ConfigurationProperties
public class SDTypeImpl implements SDType {
/*It has various services implementation that use following method**/
private SDObj getObj (BigDecimal value) {
AnnotationConfigApplicationContext context =
new AnnotationConfigApplicationContext(
SDTypeImpl.class);
SDObj obj = context.getBean(SDPropertiesUtil.class).getObj(value);
context.close();
return obj;
}
}
또 다른 클래스 :
public class SDPropertiesUtil {
@Autowired
public Environment env;
public SDObj getObj(BigDecimal value) {
String valueStr = env.getProperty(value.toString());
/*do logic*/
}
내 응용 프로그램이 시작하지만 속성 내 자식 저장소에서 파일을로드 할 수 없습니다. 내가 외부에서 application.properties를 사용하여 내 응용 프로그램을 말하고
@PropertySource("application.properties")
@ConfigurationProperties
을 사용하고 있기 때문에
나는 내 응용 프로그램에서 SRC/메인/자원에서 application.properties을한다고 생각하지만, 내부 속성 파일을 사용하지 마십시오. 그러나 이것은 일어나지 않습니다. 내 응용 프로그램은 여전히 내부 속성 파일을 사용하고 있습니다.
@PraneethRamesh 당신은 무슨 일이 일어나고 있는지 알고 :
상세한 튜토리얼
은 내 블로그에서 볼 수 있습니다? – Tiya