新建了一个 圈子表、重启tomcat 后、该表成功创建
在用户 实体中配置了用户关注圈子 用户 VS 圈子的关联表、重启tomcat 后并没有自动创建该表、
请问什么地方还需要配置吗?@wendal
@wendal 圈子表已经成功创建了、现在就是 表"t_user_circle" 没有自动创建呢
报错信息
2018-01-19 19:54:36 Get Connection from DataSource for JdbcExpert, if you lock at here, check your database server and configure
2018-01-19 19:54:36 Remove object 'myDao' from [app]
2018-01-19 19:54:36 Remove object 'dataServiceImpl' from [app]
2018-01-19 19:54:36 Remove object 'testCustomRealmMd5' from [app]
2018-01-19 19:54:36 Error@/naxxm/login :
org.nutz.ioc.IocException: IocBean[testCustomRealmMd5] throw Exception when creating
at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:150)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:216)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:245)
at org.nutz.mvc.impl.processor.ModuleProcessor.process(ModuleProcessor.java:116)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.EncodingProcessor.process(EncodingProcessor.java:27)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.UpdateRequestAttributesProcessor.process(UpdateRequestAttributesProcessor.java:15)
at org.nutz.mvc.impl.NutActionChain.doChain(NutActionChain.java:44)
at org.nutz.mvc.impl.ActionInvoker.invoke(ActionInvoker.java:67)
at org.nutz.mvc.ActionHandler.handle(ActionHandler.java:31)
at org.nutz.mvc.NutFilter.doFilter(NutFilter.java:202)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.alibaba.druid.support.http.WebStatFilter.doFilter(WebStatFilter.java:123)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:61)
at org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108)
at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137)
at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66)
at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449)
at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)
at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)
at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)
at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:383)
at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)
at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:606)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.RuntimeException: IocBean[testCustomRealmMd5] fail at field=[dataService]
at org.nutz.ioc.weaver.FieldInjector.inject(FieldInjector.java:40)
at org.nutz.ioc.weaver.DefaultWeaver.fill(DefaultWeaver.java:56)
at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:136)
... 40 more
Caused by: org.nutz.ioc.IocException: IocBean[dataServiceImpl] throw Exception when creating
at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:150)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:216)
at org.nutz.ioc.impl.NutIoc.getByType(NutIoc.java:407)
at org.nutz.ioc.val.ReferTypeValue.get(ReferTypeValue.java:66)
at org.nutz.ioc.weaver.FieldInjector.inject(FieldInjector.java:32)
... 42 more
Caused by: java.lang.RuntimeException: IocBean[dataServiceImpl] fail at field=[myDao]
at org.nutz.ioc.weaver.FieldInjector.inject(FieldInjector.java:40)
at org.nutz.ioc.weaver.DefaultWeaver.fill(DefaultWeaver.java:56)
at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:136)
... 46 more
Caused by: org.nutz.ioc.IocException: IocBean[myDao] throw Exception when creating
at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:150)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:216)
at org.nutz.ioc.val.ReferTypeValue.get(ReferTypeValue.java:60)
at org.nutz.ioc.weaver.FieldInjector.inject(FieldInjector.java:32)
... 48 more
Caused by: org.nutz.lang.InvokingException: Fail to invoke [com.naxxm.MyDataSource].myDao() by args:
For the reason: null
at org.nutz.lang.Invoking.invoke(Invoking.java:195)
at org.nutz.lang.Mirror.invoke(Mirror.java:1120)
at org.nutz.ioc.impl.ObjectMakerImpl$1.born(ObjectMakerImpl.java:78)
at org.nutz.ioc.weaver.DefaultWeaver.born(DefaultWeaver.java:67)
at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:115)
... 51 more
Caused by: java.lang.NullPointerException
at com.naxxm.MyDataSource.getConnection(MyDataSource.java:51)
at org.nutz.trans.Trans.getConnectionAuto(Trans.java:263)
at org.nutz.dao.jdbc.Jdbcs.getExpert(Jdbcs.java:106)
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:105)
at com.naxxm.MyDataSource.myDao(MyDataSource.java:34)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.nutz.lang.Invoking$NullArgInvoker.invoke(Invoking.java:77)
at org.nutz.lang.Invoking.invoke(Invoking.java:192)
... 55 more
MyDataSource类
package com.naxxm;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.logging.Logger;
import javax.servlet.http.HttpServletRequest;
import javax.sql.DataSource;
import org.nutz.dao.Dao;
import org.nutz.dao.impl.NutDao;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.Lang;
import org.nutz.log.Log;
import org.nutz.log.Logs;
import org.nutz.mvc.Mvcs;
import com.naxxm.bean.system.SysCompany;
@IocBean
public class MyDataSource implements DataSource {
private static final Log log = Logs.get();
@Inject
Dao dao; // 注入主库
@Inject
DataSource dataSource; // 注入主库的数据源
@IocBean(name = "myDao")
// 通过@IocBean工厂方法,声明一个用于操作子库的Dao实例
public Dao myDao() {
return new NutDao(this);
}
/**
* 这是唯一会被NutDao调用的方法
*/
public Connection getConnection() throws SQLException {
Connection conn = null;;
HttpServletRequest req = Mvcs.getReq();
if (req == null) { // 非request上下文? 那就用主库的连接
return dataSource.getConnection();
}
// 通过自定义逻辑拿到数据库信息(maybe需要做个map缓存一下)
SysCompany companyDB = (SysCompany) Mvcs.getSessionAttrSafe("companyDB");
String[] DBInfo = companyDB.getDBInfo().split(",");
// String driverClassName = "net.sourceforge.jtds.jdbc.Driver";
String jdbcUrl = DBInfo[0];
String username = DBInfo[1];
String password = DBInfo[2];
System.out.println("------------------------------------------------------------------------------------------------");
System.out.println(companyDB.getMc() + "---" + DBInfo[0] + "---" + DBInfo[1] + "---" + DBInfo[2]);
System.out.println("------------------------------------------------------------------------------------------------");
// Lang.loadClass(driverClassName);
try {
conn = DriverManager.getConnection(jdbcUrl, username, password);
System.out.println("--->系统数据库:公司信息正常!");
} catch (RuntimeException e) {
System.out.println("--->系统数据库:公司信息不存在" + e.getMessage());
}
return conn;
}
public void setDriverClassName(String driverClassName) throws ClassNotFoundException {
Lang.loadClass(driverClassName);
}
// 加载Nutz所支持的数据库的驱动!!
static {
String[] drivers = { "org.h2.Driver", "com.ibm.db2.jcc.DB2Driver", "org.hsqldb.jdbcDriver", "oracle.jdbc.OracleDriver", "org.postgresql.Driver", "net.sourceforge.jtds.jdbc.Driver",
"com.microsoft.sqlserver.jdbc.SQLServerDriver", "org.sqlite.JDBC", "com.mysql.jdbc.Driver", "com.beyondb.jdbc.BeyondbDriver" };
for (String driverClassName : drivers) {
try {
Class.forName(driverClassName);
} catch (Throwable e) {
}
}
}
public PrintWriter getLogWriter() throws SQLException {
throw Lang.noImplement();
}
public void setLogWriter(PrintWriter out) throws SQLException {
throw Lang.noImplement();
}
public void setLoginTimeout(int seconds) throws SQLException {
throw Lang.noImplement();
}
public int getLoginTimeout() throws SQLException {
throw Lang.noImplement();
}
public <T> T unwrap(Class<T> iface) throws SQLException {
throw Lang.noImplement();
}
public boolean isWrapperFor(Class<?> iface) throws SQLException {
throw Lang.noImplement();
}
public Connection getConnection(String username, String password) throws SQLException {
throw Lang.noImplement();
}
public Logger getParentLogger() {
throw Lang.noImplement();
}
}
添加下麦呢这段就报错
@IocBean(name = "myDao")
// 通过@IocBean工厂方法,声明一个用于操作子库的Dao实例
public Dao myDao() {
return new NutDao(this);
}