报错信息
[DEBUG] 21:25:08.045 org.nutz.ioc.impl.NutIoc.get(NutIoc.java:166) - Get 'conf'<class org.nutz.ioc.impl.PropertiesProxy>
[DEBUG] 21:25:08.046 org.nutz.ioc.impl.ScopeContext.remove(ScopeContext.java:85) - Remove object 'webApiMainLauncher' from [app]
[ERROR] 21:25:08.046 org.nutz.boot.NbApp.execute(NbApp.java:219) - something happen!!
org.nutz.ioc.IocException: IocBean[webApiMainLauncher] throw Exception when creating
at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:152)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:241)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:271)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:161)
at org.nutz.boot.NbApp.execute(NbApp.java:209)
at org.nutz.boot.NbApp.run(NbApp.java:178)
at cn.wizzer.app.web.commons.core.WebApiMainLauncher.main(WebApiMainLauncher.java:28)
Caused by: java.lang.NullPointerException
at cn.wizzer.app.web.commons.utils.unionpay.acp.sdk.SDKConfig.loadPropertiesFromSrc(SDKConfig.java:247)
at cn.wizzer.app.web.commons.core.WebApiMainLauncher.init(WebApiMainLauncher.java:32)
at cn.wizzer.app.web.commons.core.WebApiMainLauncher$FM$init$10583fbff8d536aad3a9d8b6141ae03e.invoke(WebApiMainLauncher.java)
at org.nutz.ioc.impl.ObjectMakerImpl$2.trigger(ObjectMakerImpl.java:180)
at org.nutz.ioc.weaver.DefaultWeaver.onCreate(DefaultWeaver.java:89)
at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:141)
... 6 more
[INFO ] 21:25:08.051 org.eclipse.jetty.server.AbstractConnector.doStop(AbstractConnector.java:341) - Stopped ServerConnector@3b96c42e{HTTP/1.1,[http/1.1]}{0.0.0.0:9001}
[INFO ] 21:25:08.051 org.eclipse.jetty.server.session.HouseKeeper.stopScavenging(HouseKeeper.java:167) - node0 Stopped scavenging
[INFO ] 21:25:08.052 org.nutz.boot.starter.nutz.mvc.NbMvcLoading.depose(NbMvcLoading.java:54) - Nutz.Mvc[nutz] is deposing ...
注册中心:
/**
* Created by wizzer on 2018/4/4.
*/
@IocBean(create = "init", depose = "depose")
@Modules(packages = "cn.wizzer")
public class WebApiMainLauncher {
private static final Log log = Logs.get();
@Inject("refer:$ioc")
private Ioc ioc;
@Inject
private PropertiesProxy conf;
public static void main(String[] args) throws Exception {
NbApp nb = new NbApp().setArgs(args).setPrintProcDoc(true);
nb.getAppContext().setMainPackage("cn.wizzer");
nb.run();
}
public void init() {
SDKConfig.getConfig().loadPropertiesFromSrc();// 从classpath加载acp_sdk.properties文件
}
public void depose() {
}
}
银联的 SDKConfig.java loadPropertiesFromSrc() 方法
/**
* 从classpath路径下加载配置参数
*/
public void loadPropertiesFromSrc() {
InputStream in = null;
try {
LogUtil.writeLog("从classpath: " +SDKConfig.class.getClassLoader().getResource("").getPath()+" 获取属性文件"+FILE_NAME);
in = SDKConfig.class.getClassLoader().getResourceAsStream(FILE_NAME);
if (null != in) {
properties = new Properties();
try {
properties.load(in);
} catch (IOException e) {
throw e;
}
} else {
LogUtil.writeErrorLog(FILE_NAME + "属性文件未能在classpath指定的目录下 "+SDKConfig.class.getClassLoader().getResource("").getPath()+" 找到!");
return;
}
loadProperties(properties);
} catch (IOException e) {
LogUtil.writeErrorLog(e.getMessage(), e);
} finally {
if (null != in) {
try {
in.close();
} catch (IOException e) {
LogUtil.writeErrorLog(e.getMessage(), e);
}
}
}
}