public void init(NutConfig conf) {
Ioc ioc = conf.getIoc();
Dao dao = ioc.get(Dao.class);
Daos.createTablesInPackage(dao, "com.zhangjie.project", false);
// 初始化默认根用户
if (dao.count(User.class) == 0) {
UserService us = ioc.get(UserService.class);
us.add("admin", "123456");
}
// 获取NutQuartzCronJobFactory从而触发计划任务的初始化与启动
ioc.get(NutQuartzCronJobFactory.class);
}
@IocBean(fields="dao")
public class UserService extends IdNameEntityService<User> {
public User add(String name, String password) {
User user = new User();
user.setName(name.trim());
user.setSalt(R.UU16());
user.setPassword(new Sha256Hash(password, user.getSalt()).toHex());
user.setCreateTime(new Date());
user.setUpdateTime(new Date());
return dao().insert(user);
}
}
[DEBUG] 11:00:55.260 org.nutz.dao.jdbc.Jdbcs.<clinit>(Jdbcs.java:90) - Jdbcs init complete
[INFO ] 11:00:55.261 org.nutz.dao.jdbc.Jdbcs.getExpert(Jdbcs.java:103) - Get Connection from DataSource for JdbcExpert, if I lock at here, check your database server and configure
Fri May 20 11:00:55 CST 2016 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
[DEBUG] 11:00:55.673 org.nutz.dao.impl.DaoSupport$1.invoke(DaoSupport.java:187) - JDBC Driver --> mysql-connector-java-5.1.38 ( Revision: fe541c166cec739c74cc727c5da96c1028b4834a )
[DEBUG] 11:00:55.673 org.nutz.dao.impl.DaoSupport$1.invoke(DaoSupport.java:188) - JDBC Name --> MySQL Connector Java
[DEBUG] 11:00:55.674 org.nutz.dao.impl.DaoSupport$1.invoke(DaoSupport.java:190) - JDBC URL --> jdbc:mysql://127.0.0.1:3306/myProject?useUnicode=true&characterEncoding=UTF-8
[DEBUG] 11:00:55.882 org.nutz.dao.impl.DaoSupport$1.invoke(DaoSupport.java:206) - Mysql : character_set_client=utf8
[DEBUG] 11:00:55.882 org.nutz.dao.impl.DaoSupport$1.invoke(DaoSupport.java:206) - Mysql : character_set_connection=utf8
[DEBUG] 11:00:55.883 org.nutz.dao.impl.DaoSupport$1.invoke(DaoSupport.java:206) - Mysql : character_set_database=utf8
[DEBUG] 11:00:55.884 org.nutz.dao.impl.DaoSupport$1.invoke(DaoSupport.java:206) - Mysql : character_set_filesystem=binary
[DEBUG] 11:00:55.884 org.nutz.dao.impl.DaoSupport$1.invoke(DaoSupport.java:206) - Mysql : character_set_results=
[DEBUG] 11:00:55.885 org.nutz.dao.impl.DaoSupport$1.invoke(DaoSupport.java:206) - Mysql : character_set_server=utf8
[DEBUG] 11:00:55.885 org.nutz.dao.impl.DaoSupport$1.invoke(DaoSupport.java:206) - Mysql : character_set_system=utf8
[DEBUG] 11:00:55.885 org.nutz.dao.impl.DaoSupport$1.invoke(DaoSupport.java:206) - Mysql : character_sets_dir=C:\Program Files\MySQL\MySQL Server 5.7\share\charsets\
[DEBUG] 11:00:55.886 org.nutz.dao.impl.DaoSupport$1.invoke(DaoSupport.java:213) - Mysql : database=myproject
[DEBUG] 11:00:55.887 org.nutz.dao.impl.DaoSupport$1.invoke(DaoSupport.java:219) - Mysql : user=root@localhost
[DEBUG] 11:00:55.937 org.nutz.dao.impl.DaoSupport$1.invoke(DaoSupport.java:227) - Mysql : 't_user_message' engine=MyISAM
[DEBUG] 11:00:55.939 org.nutz.dao.impl.DaoSupport.setDataSource(DaoSupport.java:234) - Database info --> MYSQL:[MySQL - 5.7.9-log]
[DEBUG] 11:00:55.958 org.nutz.resource.Scans.scan(Scans.java:233) - Found 28 resource by src( com/zhangjie/project/ ) , regex( ^.+[.]class$ )
[INFO ] 11:00:55.967 org.nutz.resource.Scans.rs2class(Scans.java:381) - Resource can't map to Class, Resource DaoUpTest.class
[DEBUG] 11:00:56.185 org.nutz.dao.impl.sql.run.NutDaoExecutor._runSelect(NutDaoExecutor.java:192) - SELECT COUNT(*) FROM t_user
[DEBUG] 11:00:56.189 org.nutz.ioc.impl.NutIoc.get(NutIoc.java:151) - Get 'userService'<class com.zhangjie.project.service.UserService>
[DEBUG] 11:00:56.190 org.nutz.ioc.impl.NutIoc.get(NutIoc.java:178) - >> Load definition name=userService
[DEBUG] 11:00:56.190 org.nutz.ioc.loader.combo.ComboIocLoader.load(ComboIocLoader.java:161) - Found IocObject(userService) in AnnotationIocLoader(packages=[com.zhangjie.project])
[DEBUG] 11:00:56.191 org.nutz.ioc.impl.NutIoc.get(NutIoc.java:208) - >> Make...'userService'<class com.zhangjie.project.service.UserService>
[DEBUG] 11:00:56.192 org.nutz.ioc.aop.impl.DefaultMirrorFactory.getMirror(DefaultMirrorFactory.java:70) - Load class com.zhangjie.project.service.UserService without AOP
[DEBUG] 11:00:56.192 org.nutz.ioc.impl.ScopeContext.save(ScopeContext.java:59) - Save object 'userService' to [app]
[DEBUG] 11:00:56.193 org.nutz.service.EntityService.<init>(EntityService.java:40) - Get TypeParams for self : com.zhangjie.project.bean.User
[DEBUG] 11:00:56.194 org.nutz.ioc.impl.NutIoc.get(NutIoc.java:151) - Get 'dao'<>
[ERROR] 11:00:56.224 org.nutz.mvc.impl.NutLoading.load(NutLoading.java:124) - Error happend during start serivce!
org.nutz.dao.DaoException: java.lang.RuntimeException: java.lang.NoSuchMethodException: com.zhangjie.project.bean.User.now()
at org.nutz.dao.impl.sql.run.NutDaoRunner.run(NutDaoRunner.java:49)
at org.nutz.dao.impl.DaoSupport.run(DaoSupport.java:250)
at org.nutz.dao.impl.DaoSupport$DaoExec.run(DaoSupport.java:317)
at org.nutz.trans.Trans.exec(Trans.java:174)
at org.nutz.dao.impl.DaoSupport._exec(DaoSupport.java:287)
at org.nutz.dao.impl.EntityOperator.exec(EntityOperator.java:50)
at org.nutz.dao.impl.NutDao.insert(NutDao.java:158)
at com.zhangjie.project.service.UserService.add(UserService.java:22)
at com.zhangjie.project.MainSetup.init(MainSetup.java:25)
at org.nutz.mvc.impl.NutLoading.evalSetup(NutLoading.java:276)
at org.nutz.mvc.impl.NutLoading.load(NutLoading.java:120)
at org.nutz.mvc.ActionHandler.<init>(ActionHandler.java:19)
at org.nutz.mvc.NutFilter._init(NutFilter.java:87)
at org.nutz.mvc.NutFilter.init(NutFilter.java:65)
at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:279)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:260)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:105)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4908)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5602)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:899)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:875)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1260)
at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:2002)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.RuntimeException: java.lang.NoSuchMethodException: com.zhangjie.project.bean.User.now()
at org.nutz.lang.Lang.wrapThrow(Lang.java:153)
at org.nutz.lang.Invoking.<init>(Invoking.java:153)
at org.nutz.lang.Mirror.getInvoking(Mirror.java:1023)
at org.nutz.lang.Mirror.invoke(Mirror.java:1100)
at org.nutz.el.opt.object.AccessOpt.run(AccessOpt.java:71)
at org.nutz.el.opt.object.MethodOpt.calculate(MethodOpt.java:45)
at org.nutz.el.opt.object.InvokeMethodOpt.calculate(InvokeMethodOpt.java:22)
at org.nutz.el.arithmetic.RPN.calculate(RPN.java:55)
at org.nutz.el.arithmetic.RPN.calculate(RPN.java:38)
at org.nutz.el.El.eval(El.java:30)
at org.nutz.dao.impl.entity.macro.ElFieldMacro.onAfter(ElFieldMacro.java:37)
at org.nutz.dao.impl.sql.run.NutDaoExecutor.exec(NutDaoExecutor.java:56)
at org.nutz.dao.impl.DaoSupport$DaoExec.invoke(DaoSupport.java:327)
at org.nutz.dao.impl.sql.run.NutDaoRunner.run(NutDaoRunner.java:38)
... 29 more
Caused by: java.lang.NoSuchMethodException: com.zhangjie.project.bean.User.now()
at java.lang.Class.getMethod(Class.java:1670)
at org.nutz.lang.Invoking.<init>(Invoking.java:88)
... 41 more
[ERROR] 11:00:56.227 org.nutz.mvc.impl.NutLoading.load(NutLoading.java:126) - try to depose ioc
精华
不知道咋搞得 忽然 MainSetup 调用Service执行insert 操作异常 之前还好的呢
标签:
dao
添加回复
请先登陆