我有以下内容:
@Service(DropboxService.NAME)
public class DropboxServiceBean implements DropboxService {
@Inject
private CustomConfig customConfig;
private final String ACCESS_TOKEN = customConfig.getDropboxAppToken();
DbxRequestConfig config = new DbxRequestConfig("dropbox/java-tutorial", "en_US");
DbxClientV2 client = new DbxClientV2(config, ACCESS_TOKEN);
有谁知道我如何才能customConfig.getDropboxAppToken();
首先加载的值。我不断收到以下错误:
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
我正在尝试的当前代码
错误:创建名为“ecosmart_BackupService”的 bean 时出错:通过字段“dropboxService”表示的依赖关系不满足;嵌套异常是 org.springframework.beans.factory.BeanCreationException:创建名为“ecosmart_DropboxService”的 bean 时出错:调用 init 方法失败;嵌套异常是 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);
}