NutzCN Logo
问答 nutzboot 多数据源打包后运行报错
发布于 2137天前 作者 qq_117e429a 1835 次浏览 复制 上一个帖子 下一个帖子
标签:

nutzboot 项目配置多数据源,idea运行测试正常
使用打成jar后运行报错
麻烦帮忙看下

import javax.sql.DataSource;

import org.nutz.dao.Dao;
import org.nutz.dao.impl.NutDao;
import org.nutz.ioc.impl.PropertiesProxy;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;

import com.alibaba.druid.pool.DruidDataSource;

@IocBean
public class DataDao {

    @Inject
    protected PropertiesProxy conf;

    @Inject protected DataSource dataSourceData ;

    @IocBean
    public Dao daoData() {
        return new NutDao(dataSourceData);
    }


    @IocBean
    public DataSource dataSourceData() {
        return conf.make(DruidDataSource.class , "jdbcdata.");
    }
}
#mysql数据库
jdbc.url=
jdbc.username=
jdbc.password=
jdbc.maxActive=100
jdbc.testWhileIdle=true
jdbc.filters=mergeStat
jdbc.connectionProperties=druid.stat.slowSqlMillis=2000


#pg  data数据库
jdbcdata.url=
jdbcdata.username=
jdbcdata.password=
jdbcdata.maxActive=100
jdbcdata.testWhileIdle=true
jdbcdata.filters=mergeStat
jdbcdata.connectionProperties=druid.stat.slowSqlMillis=2000

错误日志

[DEBUG] 14:25:34.024 org.nutz.ioc.impl.ScopeContext.save(ScopeContext.java:65) - Save object 'dataDao' to [app]
[DEBUG] 14:25:34.025 org.nutz.ioc.aop.impl.DefaultMirrorFactory.getMirror(DefaultMirrorFactory.java:76) - Load class net.yubodata.push.config.dao.DataDao without AOP
[DEBUG] 14:25:34.026 org.nutz.ioc.impl.NutIoc.get(NutIoc.java:166) - Get 'conf'<class org.nutz.ioc.impl.PropertiesProxy>
[DEBUG] 14:25:34.026 org.nutz.ioc.impl.NutIoc.get(NutIoc.java:166) - Get 'dataSourceData'<interface javax.sql.DataSource>
[DEBUG] 14:25:34.027 org.nutz.ioc.impl.NutIoc.get(NutIoc.java:192) -     >> Load definition name=dataSourceData
[DEBUG] 14:25:34.027 org.nutz.ioc.loader.combo.ComboIocLoader.printFoundIocBean(ComboIocLoader.java:226) - Found IocObject(dataSourceData) in AnnotationIocLoader(packages=[net.yubodata.push])
[DEBUG] 14:25:34.028 org.nutz.ioc.impl.NutIoc.get(NutIoc.java:223) -     >> Make...'dataSourceData'<interface javax.sql.DataSource>
[DEBUG] 14:25:34.028 org.nutz.ioc.impl.ScopeContext.save(ScopeContext.java:65) - Save object 'dataSourceData' to [app]
[DEBUG] 14:25:34.029 org.nutz.ioc.impl.NutIoc.get(NutIoc.java:166) - Get 'dataDao'<>
[DEBUG] 14:25:34.166 org.nutz.dao.jdbc.Jdbcs.<clinit>(Jdbcs.java:93) - Jdbcs init complete
[INFO ] 14:25:34.166 org.nutz.dao.jdbc.Jdbcs.getExpert(Jdbcs.java:106) - Get Connection from DataSource for JdbcExpert, if you lock at here, check your database server and configure
[ERROR] 14:25:34.244 com.alibaba.druid.pool.DruidDataSource.init(DruidDataSource.java:922) - {dataSource-1} init error
java.sql.SQLException: url not set
        at com.alibaba.druid.pool.DruidDataSource.init(DruidDataSource.java:828)
        at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:1246)
        at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:1242)
        at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:89)
        at org.nutz.trans.Trans.getConnectionAuto(Trans.java:263)
        at org.nutz.dao.jdbc.Jdbcs.getExpert(Jdbcs.java:109)
        at org.nutz.dao.impl.DaoSupport.setDataSource(DaoSupport.java:187)
        at org.nutz.dao.impl.DaoSupport.setDataSource(DaoSupport.java:178)
        at org.nutz.dao.impl.NutDao.<init>(NutDao.java:108)
        at net.yubodata.push.config.dao.DataDao.daoData(DataDao.java:28)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.nutz.lang.Invoking$NullArgInvoker.invoke(Invoking.java:77)
        at org.nutz.lang.Invoking.invoke(Invoking.java:192)
        at org.nutz.lang.Mirror.invoke(Mirror.java:1132)
        at org.nutz.ioc.impl.ObjectMakerImpl$1.born(ObjectMakerImpl.java:80)
        at org.nutz.ioc.weaver.DefaultWeaver.born(DefaultWeaver.java:78)
        at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:117)
        at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:241)
        at org.nutz.ioc.val.ReferTypeValue.get(ReferTypeValue.java:60)
        at org.nutz.ioc.weaver.FieldInjector.inject(FieldInjector.java:32)
        at org.nutz.ioc.weaver.DefaultWeaver.fill(DefaultWeaver.java:67)
        at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:138)
        at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:241)
        at org.nutz.ioc.val.ReferTypeValue.get(ReferTypeValue.java:60)
        at org.nutz.ioc.weaver.FieldInjector.inject(FieldInjector.java:32)
        at org.nutz.ioc.weaver.DefaultWeaver.fill(DefaultWeaver.java:67)
        at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:138)
        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:210)
        at org.nutz.boot.NbApp.run(NbApp.java:178)
        at net.yubodata.push.MainLauncher.main(MainLauncher.java:41)
[DEBUG] 14:25:34.246 org.nutz.ioc.impl.ScopeContext.remove(ScopeContext.java:85) - Remove object 'daoData' from [app]
[DEBUG] 14:25:34.248 org.nutz.ioc.impl.ScopeContext.remove(ScopeContext.java:85) - Remove object 'pushService' from [app]
[DEBUG] 14:25:34.249 org.nutz.ioc.impl.ScopeContext.remove(ScopeContext.java:85) - Remove object 'mainLauncher' from [app]
[ERROR] 14:25:34.249 org.nutz.boot.NbApp.execute(NbApp.java:220) - something happen!!
org.nutz.ioc.IocException: IocBean[mainLauncher] 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:210)
        at org.nutz.boot.NbApp.run(NbApp.java:178)
        at net.yubodata.push.MainLauncher.main(MainLauncher.java:41)
Caused by: java.lang.RuntimeException: IocBean[mainLauncher] fail at field=[pushService]
        at org.nutz.ioc.weaver.FieldInjector.inject(FieldInjector.java:40)
        at org.nutz.ioc.weaver.DefaultWeaver.fill(DefaultWeaver.java:67)
        at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:138)
        ... 6 more
Caused by: org.nutz.ioc.IocException: IocBean[pushService] 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.val.ReferTypeValue.get(ReferTypeValue.java:60)
        at org.nutz.ioc.weaver.FieldInjector.inject(FieldInjector.java:32)
        ... 8 more
Caused by: java.lang.RuntimeException: IocBean[pushService] fail at field=[daoData]
        at org.nutz.ioc.weaver.FieldInjector.inject(FieldInjector.java:40)
        at org.nutz.ioc.weaver.DefaultWeaver.fill(DefaultWeaver.java:67)
        at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:138)
        ... 11 more
Caused by: org.nutz.ioc.IocException: IocBean[daoData] 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.val.ReferTypeValue.get(ReferTypeValue.java:60)
        at org.nutz.ioc.weaver.FieldInjector.inject(FieldInjector.java:32)
        ... 13 more
Caused by: org.nutz.lang.InvokingException: Fail to invoke [net.yubodata.push.config.dao.DataDao].daoData() by args:

For the reason: url not set
        at org.nutz.lang.Invoking.invoke(Invoking.java:195)
        at org.nutz.lang.Mirror.invoke(Mirror.java:1132)
        at org.nutz.ioc.impl.ObjectMakerImpl$1.born(ObjectMakerImpl.java:80)
        at org.nutz.ioc.weaver.DefaultWeaver.born(DefaultWeaver.java:78)
        at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:117)
        ... 16 more
Caused by: java.sql.SQLException: url not set
        at com.alibaba.druid.pool.DruidDataSource.init(DruidDataSource.java:828)
        at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:1246)
        at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:1242)
        at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:89)
        at org.nutz.trans.Trans.getConnectionAuto(Trans.java:263)
        at org.nutz.dao.jdbc.Jdbcs.getExpert(Jdbcs.java:109)
        at org.nutz.dao.impl.DaoSupport.setDataSource(DaoSupport.java:187)
        at org.nutz.dao.impl.DaoSupport.setDataSource(DaoSupport.java:178)
        at org.nutz.dao.impl.NutDao.<init>(NutDao.java:108)
        at net.yubodata.push.config.dao.DataDao.daoData(DataDao.java:28)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.nutz.lang.Invoking$NullArgInvoker.invoke(Invoking.java:77)
        at org.nutz.lang.Invoking.invoke(Invoking.java:192)
        ... 20 more
[INFO ] 14:25:34.250 org.quartz.core.QuartzScheduler.shutdown(QuartzScheduler.java:666) - Scheduler NutzbootScheduler_$_NON_CLUSTERED shutting down.
[INFO ] 14:25:34.250 org.quartz.core.QuartzScheduler.standby(QuartzScheduler.java:585) - Scheduler NutzbootScheduler_$_NON_CLUSTERED paused.
[DEBUG] 14:25:34.251 org.quartz.simpl.SimpleThreadPool.shutdown(SimpleThreadPool.java:328) - Shutting down threadpool...
[DEBUG] 14:25:34.689 org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:612) - WorkerThread is shut down.
[DEBUG] 14:25:34.689 org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:612) - WorkerThread is shut down.
[DEBUG] 14:25:34.689 org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:612) - WorkerThread is shut down.
[DEBUG] 14:25:34.689 org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:612) - WorkerThread is shut down.
[DEBUG] 14:25:34.691 org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:612) - WorkerThread is shut down.
[DEBUG] 14:25:34.691 org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:612) - WorkerThread is shut down.
[DEBUG] 14:25:34.691 org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:612) - WorkerThread is shut down.
[DEBUG] 14:25:34.691 org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:612) - WorkerThread is shut down.
[DEBUG] 14:25:34.708 org.quartz.simpl.SimpleThreadPool.shutdown(SimpleThreadPool.java:393) - No executing jobs remaining, all threads stopped.
[DEBUG] 14:25:34.709 org.quartz.simpl.SimpleThreadPool.shutdown(SimpleThreadPool.java:395) - Shutdown of threadpool complete.
[INFO ] 14:25:34.709 org.quartz.core.QuartzScheduler.shutdown(QuartzScheduler.java:740) - Scheduler NutzbootScheduler_$_NON_CLUSTERED shutdown complete.
[INFO ] 14:25:34.710 org.apache.coyote.AbstractProtocol.pause(AbstractProtocol.java:609) - Pausing ProtocolHandler ["http-nio-8080"]
[INFO ] 14:25:34.739 org.apache.catalina.core.StandardService.stopInternal(StandardService.java:480) - Stopping service [Tomcat]
[INFO ] 14:25:34.742 org.nutz.boot.starter.nutz.mvc.NbMvcLoading.depose(NbMvcLoading.java:54) - Nutz.Mvc[nutz] is deposing ...
[INFO ] 14:25:34.743 org.nutz.boot.starter.nutz.mvc.NbMvcLoading.depose(NbMvcLoading.java:70) - Nutz.Mvc[nutz] is down in 0ms
[INFO ] 14:25:34.752 org.apache.coyote.AbstractProtocol.stop(AbstractProtocol.java:629) - Stopping ProtocolHandler ["http-nio-8080"]
[INFO ] 14:25:34.756 org.nutz.ioc.impl.NutIoc.depose(NutIoc.java:287) - org.nutz.ioc.impl.NutIoc@90767234 is closing. startup date [19-01-08 14:25:33.139]
[DEBUG] 14:25:34.756 org.nutz.ioc.impl.ScopeContext.clear(ScopeContext.java:109) - Depose object 'dataDao' ...
[DEBUG] 14:25:34.757 org.nutz.ioc.impl.ScopeContext.clear(ScopeContext.java:109) - Depose object 'nutFilter' ...
[DEBUG] 14:25:34.757 org.nutz.ioc.impl.ScopeContext.clear(ScopeContext.java:109) - Depose object 'whaleFilter' ...
[DEBUG] 14:25:34.758 org.nutz.ioc.impl.ScopeContext.clear(ScopeContext.java:109) - Depose object 'nutQuartzCronJobFactory' ...
[DEBUG] 14:25:34.758 org.nutz.ioc.impl.ScopeContext.clear(ScopeContext.java:109) - Depose object 'quartzManager' ...
[DEBUG] 14:25:34.758 org.nutz.ioc.impl.ScopeContext.clear(ScopeContext.java:109) - Depose object 'nbServletContextListener' ...
[DEBUG] 14:25:34.759 org.nutz.ioc.impl.ScopeContext.clear(ScopeContext.java:109) - Depose object 'whaleFilterStarter' ...
[DEBUG] 14:25:34.761 org.nutz.ioc.impl.ScopeContext.clear(ScopeContext.java:109) - Depose object 'nutFilterStarter' ...
[DEBUG] 14:25:34.762 org.nutz.ioc.impl.ScopeContext.clear(ScopeContext.java:109) - Depose object 'swaggerServletStarter' ...
[DEBUG] 14:25:34.763 org.nutz.ioc.impl.ScopeContext.clear(ScopeContext.java:109) - Depose object 'tomcatStarter' ...
[DEBUG] 14:25:34.763 org.nutz.ioc.impl.ScopeContext.clear(ScopeContext.java:109) - Depose object 'quartzStarter' ...
[DEBUG] 14:25:34.763 org.nutz.ioc.impl.ScopeContext.clear(ScopeContext.java:109) - Depose object 'druidWebStatServletStarter' ...
[DEBUG] 14:25:34.764 org.nutz.ioc.impl.ScopeContext.clear(ScopeContext.java:109) - Depose object 'druidWebStatFilterStarter' ...
[DEBUG] 14:25:34.764 org.nutz.ioc.impl.ScopeContext.clear(ScopeContext.java:109) - Depose object 'dataSourceStarter' ...
[DEBUG] 14:25:34.764 org.nutz.boot.starter.jdbc.DataSourceStarter.depose(DataSourceStarter.java:256) - shutdown slave datasource count=0
[DEBUG] 14:25:34.766 org.nutz.ioc.impl.ScopeContext.clear(ScopeContext.java:109) - Depose object 'nutDaoStarter' ...
[DEBUG] 14:25:34.767 org.nutz.ioc.impl.ScopeContext.clear(ScopeContext.java:109) - Depose object '$aop_async' ...
[DEBUG] 14:25:34.767 org.nutz.ioc.impl.ScopeContext.clear(ScopeContext.java:109) - Depose object 'scheduler' ...
[DEBUG] 14:25:34.767 org.nutz.ioc.impl.ScopeContext.clear(ScopeContext.java:109) - Depose object 'counterService' ...
[DEBUG] 14:25:34.768 org.nutz.ioc.impl.ScopeContext.clear(ScopeContext.java:109) - Depose object 'nbApp' ...
[DEBUG] 14:25:34.768 org.nutz.ioc.impl.ScopeContext.clear(ScopeContext.java:109) - Depose object 'conf' ...
[DEBUG] 14:25:34.768 org.nutz.ioc.impl.ScopeContext.clear(ScopeContext.java:109) - Depose object 'appContext' ...
[DEBUG] 14:25:34.769 org.nutz.ioc.impl.ScopeContext.clear(ScopeContext.java:114) - Depose object 'dataSourceData' ...
[INFO ] 14:25:34.770 org.nutz.ioc.impl.NutIoc.depose(NutIoc.java:301) - org.nutz.ioc.impl.NutIoc@90767234 is deposed. startup date [19-01-08 14:25:33.139]
9 回复

用winrar打开jar文件,检查里面的application.properties是否正确

nutz.boot.configure.properties.dir=config

配置是正常的

啥意思? 配置文件在外部? config目录里面? 是不是忘记加了

application.properties

nutz.boot.configure.properties.dir=config

/config/jdbc.properties

#mysql数据库
jdbc.url=
jdbc.username=
jdbc.password=
jdbc.maxActive=100
jdbc.testWhileIdle=true
jdbc.filters=mergeStat
jdbc.connectionProperties=druid.stat.slowSqlMillis=2000


#pg  data数据库
jdbcdata.url=
jdbcdata.username=
jdbcdata.password=
jdbcdata.maxActive=100
jdbcdata.testWhileIdle=true
jdbcdata.filters=mergeStat
jdbcdata.connectionProperties=druid.stat.slowSqlMillis=2000

配置文件是有的,在idea运行没问题 打成jar后用 java -jar 运行就报错了

是不是用了把配置文件打到外面的功能,检查下config目录里有配置文件没有

config目录下有jdbc.properties

我现在将配置文件的内容都放到application.properties 就可以用了

添加回复
请先登陆
回到顶部