我的基础框架做了一些封装,会依赖nutz.dao , 但是有些场景是要依赖框架包,但不需要数据库相关操作,如果不配置数据源和nutz.dao 相关配置,就会报一下信息,有没有什么办法不让nutz.dao starter 中的配置起效?
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dao' defined in class path resource [org/nutz/plugin/spring/boot/NutzDaoAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.nutz.dao.Dao]: Factory method 'dao' threw exception; nested exception is java.lang.NullPointerException
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:599) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1173) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1067) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867) ~[spring-context-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543) ~[spring-context-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) [spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) [spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) [spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) [spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) [spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE]
at cn.sayyoo.zuul.ZuulApplication.main(ZuulApplication.java:10) [classes/:na]
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.nutz.dao.Dao]: Factory method 'dao' threw exception; nested exception is java.lang.NullPointerException
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
... 18 common frames omitted
Caused by: java.lang.NullPointerException: null
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:307) ~[na:1.8.0_121]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_121]
at com.alibaba.druid.util.JdbcUtils.createDriver(JdbcUtils.java:556) ~[druid-1.1.2.jar:1.1.2]
at com.alibaba.druid.pool.DruidDataSource.init(DruidDataSource.java:757) ~[druid-1.1.2.jar:1.1.2]
at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:1129) ~[druid-1.1.2.jar:1.1.2]
at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:1125) ~[druid-1.1.2.jar:1.1.2]
at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:104) ~[druid-1.1.2.jar:1.1.2]
at org.nutz.trans.Trans.getConnectionAuto(Trans.java:263) ~[nutz-1.r.63-20171103.015144-135.jar:1.r.63-SNAPSHOT]
at org.nutz.dao.jdbc.Jdbcs.getExpert(Jdbcs.java:106) ~[nutz-1.r.63-20171103.015144-135.jar:1.r.63-SNAPSHOT]
at org.nutz.dao.impl.DaoSupport.setDataSource(DaoSupport.java:187) ~[nutz-1.r.63-20171103.015144-135.jar:1.r.63-SNAPSHOT]
at org.nutz.dao.impl.DaoSupport.setDataSource(DaoSupport.java:178) ~[nutz-1.r.63-20171103.015144-135.jar:1.r.63-SNAPSHOT]
at org.nutz.dao.impl.NutDao.<init>(NutDao.java:105) ~[nutz-1.r.63-20171103.015144-135.jar:1.r.63-SNAPSHOT]
at org.nutz.dao.impl.NutDao.<init>(NutDao.java:109) ~[nutz-1.r.63-20171103.015144-135.jar:1.r.63-SNAPSHOT]
at org.nutz.plugin.spring.boot.NutzDaoAutoConfiguration.dao(NutzDaoAutoConfiguration.java:34) ~[nutz-plugins-spring-boot-starter-1.r.63-SNAPSHOT.jar:na]
at org.nutz.plugin.spring.boot.NutzDaoAutoConfiguration$$EnhancerBySpringCGLIB$$9fce44d5.CGLIB$dao$0(<generated>) ~[nutz-plugins-spring-boot-starter-1.r.63-SNAPSHOT.jar:na]
at org.nutz.plugin.spring.boot.NutzDaoAutoConfiguration$$EnhancerBySpringCGLIB$$9fce44d5$$FastClassBySpringCGLIB$$ccf95698.invoke(<generated>) ~[nutz-plugins-spring-boot-starter-1.r.63-SNAPSHOT.jar:na]
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228) ~[spring-core-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:358) ~[spring-context-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.nutz.plugin.spring.boot.NutzDaoAutoConfiguration$$EnhancerBySpringCGLIB$$9fce44d5.dao(<generated>) ~[nutz-plugins-spring-boot-starter-1.r.63-SNAPSHOT.jar:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_121]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_121]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_121]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_121]
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
... 19 common frames omitted
Process finished with exit code 1