나는 다음 있습니다. 'ecosmart_BackupService'이름을 가진 bean을 생성 오류 :콩 인스턴스화 주문
Caused by: org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'myApp_DropboxService' defined in URL
[jar:file:/E:/Cuba/myApp/deploy/tomcat/webapps/app-core/WEB-INF/lib/app-core-0.1-SNAPSHOT.jar!/com/daryn/myApp/service/DropboxServiceBean.class]:
Instantiation of bean failed; nested exception is
org.springframework.beans.BeanInstantiationException: Failed to
instantiate [com.daryn.myapp.service.DropboxServiceBean]: Constructor
threw exception; nested exception is java.lang.NullPointerException
현재 코드 내가
오류를 시도하고있다 : 나는 다음과 같은 오류가 계속 불만족 종속성 필드 'dropboxService'을 통해 표현을; 중첩 예외는 org.springframework.beans.factory.BeanCreationException입니다 : 이름 'ecosmart_DropboxService'로 bean을 생성하는 중 오류가 발생했습니다 : init 메소드를 호출하지 못했습니다. 상자의 예외는 봄 개체가 구축 된 후에 만 필드를 주입하고 ACCESS_TOKEN
도 그 전에 초기화 귀하의 경우 java.lang.NullPointerException이
@Service(DropboxService.NAME)
public class DropboxServiceBean implements DropboxService {
@Inject
private CustomConfig customConfig;
private String ACCESS_TOKEN = "";
DbxRequestConfig config;
DbxClientV2 client;
@PostConstruct
public void postConstruct() {
System.out.println("**************Running post construct");
ACCESS_TOKEN = customConfig.getDropboxAppToken();
config = new DbxRequestConfig("dropbox/java-tutorial", "en_US");
client = new DbxClientV2(config, ACCESS_TOKEN);
}
주석을'@ PostConstruct' 주석에 넣으십시오. 주입은 객체가 생성 된 후에 만 발생할 수 있습니다. –
@postconstruct를 사용하여 업데이트했습니다. 그러나 여전히 작동하지 않습니다. 아마도 CustomConfig bean이 부팅 할 때까지 bean이 인스턴스화되기 때문일 것입니다 ... – Daryn
당신은'myApp_DropboxService'로 시작했고 이제'ecosmart_BackupService'에 문제가 있습니다. 그래서 문제는 아마도이 클래스의 코드와 같습니다 . – Oleg