NutzCN Logo
问答 关于Setup:实现Setup并不进入init方法,不报错。
发布于 2372天前 作者 疯子 1863 次浏览 复制 上一个帖子 下一个帖子
标签:

如题

public class MainSetup implements Setup {

	@Override
	public void destroy(NutConfig nc) {
		// TODO Auto-generated method stub

	}

	@Override
	public void init(NutConfig nc) {
		System.out.println("===========================");
		Ioc ioc = nc.getIoc();
		Dao dao = ioc.get(Dao.class);
		// 如果没有createTablesInPackage,请检查nutz版本
		Daos.createTablesInPackage(dao, "net.wendal.nutzbook", false);
		// 初始化默认根用户
		if (dao.count(User.class) == 0) {
			User user = new User();
			user.setName("admin");
			user.setPassword("123456");
			user.setCreateTime(new Date());
			user.setUpdateTime(new Date());
			dao.insert(user);
		}
	}

}
@SetupBy(value = MainSetup.class)
@IocBy(type = ComboIocProvider.class, args = { "*js", "ioc/", "*anno", "net.wendal.nutzbook", "*tx", "*async" })
@Modules(scanPackage = true)
public class nutzbook {

}
2018-5-19 19:4:47.97 INFO [main] Select SystemLog as Nutz.Log implement
2018-5-19 19:4:47.111 INFO [main] NutFilter[nutz] starting ...
2018-5-19 19:4:48.2 DEBUG [main] Locations for Scans:
[Dir[path=E:\a\eclipse], Jar[path=E:\eclipse-workspace\maven\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\nutzbook\WEB-INF\lib\nutz-1.r.60.jar], Jar[path=E:\a\Java\jdk1.8.0_151\jre\lib\resources.jar], Jar[path=E:\a\Java\jdk1.8.0_151\jre\lib\rt.jar], Jar[path=E:\a\Java\jdk1.8.0_151\jre\lib\jsse.jar], Jar[path=E:\a\Java\jdk1.8.0_151\jre\lib\jce.jar], Jar[path=E:\a\Java\jdk1.8.0_151\jre\lib\charsets.jar], Jar[path=E:\a\Java\jdk1.8.0_151\jre\lib\jfr.jar], Jar[path=E:\b\apache-tomcat-9.0.2\bin\bootstrap.jar], Jar[path=E:\b\apache-tomcat-9.0.2\bin\tomcat-juli.jar], Jar[path=E:\a\Java\jdk1.8.0_151\lib\tools.jar]]
2018-5-19 19:4:48.143 DEBUG [main] Locations for Scans:
{E:\a\eclipse=Dir[path=E:\a\eclipse], E:\eclipse-workspace\maven\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\nutzbook\WEB-INF\lib\nutz-1.r.60.jar=Jar[path=E:\eclipse-workspace\maven\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\nutzbook\WEB-INF\lib\nutz-1.r.60.jar], E:\a\Java\jdk1.8.0_151\jre\lib\resources.jar=Jar[path=E:\a\Java\jdk1.8.0_151\jre\lib\resources.jar], E:\a\Java\jdk1.8.0_151\jre\lib\rt.jar=Jar[path=E:\a\Java\jdk1.8.0_151\jre\lib\rt.jar], E:\a\Java\jdk1.8.0_151\jre\lib\jsse.jar=Jar[path=E:\a\Java\jdk1.8.0_151\jre\lib\jsse.jar], E:\a\Java\jdk1.8.0_151\jre\lib\jce.jar=Jar[path=E:\a\Java\jdk1.8.0_151\jre\lib\jce.jar], E:\a\Java\jdk1.8.0_151\jre\lib\charsets.jar=Jar[path=E:\a\Java\jdk1.8.0_151\jre\lib\charsets.jar], E:\a\Java\jdk1.8.0_151\jre\lib\jfr.jar=Jar[path=E:\a\Java\jdk1.8.0_151\jre\lib\jfr.jar], E:\b\apache-tomcat-9.0.2\bin\bootstrap.jar=Jar[path=E:\b\apache-tomcat-9.0.2\bin\bootstrap.jar], E:\b\apache-tomcat-9.0.2\bin\tomcat-juli.jar=Jar[path=E:\b\apache-tomcat-9.0.2\bin\tomcat-juli.jar], E:\a\Java\jdk1.8.0_151\lib\tools.jar=Jar[path=E:\a\Java\jdk1.8.0_151\lib\tools.jar], E:\eclipse-workspace\maven\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\nutzbook\WEB-INF\classes=Dir[path=E:\eclipse-workspace\maven\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\nutzbook\WEB-INF\classes], E:\eclipse-workspace\maven\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\nutzbook\WEB-INF\lib\druid-1.0.26.jar=Jar[path=E:\eclipse-workspace\maven\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\nutzbook\WEB-INF\lib\druid-1.0.26.jar], E:\eclipse-workspace\maven\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\nutzbook\WEB-INF\lib\mysql-connector-java-5.1.40.jar=Jar[path=E:\eclipse-workspace\maven\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\nutzbook\WEB-INF\lib\mysql-connector-java-5.1.40.jar]}
2018-5-19 19:4:48.243 DEBUG [main] Using 95 castor for Castors
2018-5-19 19:4:48.258 DEBUG [main] Loading by class org.nutz.mvc.impl.NutLoading
2018-5-19 19:4:48.258 INFO [main] Nutz Version : 1.r.60 
2018-5-19 19:4:48.258 INFO [main] Nutz.Mvc[nutz] is initializing ...
2018-5-19 19:4:48.258 DEBUG [main] Web Container Information:
2018-5-19 19:4:48.258 DEBUG [main]  - Default Charset : UTF-8
2018-5-19 19:4:48.258 DEBUG [main]  - Current . path  : E:\a\eclipse\.
2018-5-19 19:4:48.258 DEBUG [main]  - Java Version    : 1.8.0_151
2018-5-19 19:4:48.258 DEBUG [main]  - File separator  : \
2018-5-19 19:4:48.258 DEBUG [main]  - Timezone        : Asia/Shanghai
2018-5-19 19:4:48.258 DEBUG [main]  - OS              : Windows 10 amd64
2018-5-19 19:4:48.258 DEBUG [main]  - ServerInfo      : Apache Tomcat/9.0.2
2018-5-19 19:4:48.258 DEBUG [main]  - Servlet API     : 4.0
2018-5-19 19:4:48.274 DEBUG [main]  - ContextPath     : /nutzbook
2018-5-19 19:4:48.274 DEBUG [main]  - context.tempdir : E:\eclipse-workspace\maven\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\work\Catalina\localhost\nutzbook
2018-5-19 19:4:48.274 DEBUG [main]  - MainModule      : org.nutz.Nutz
2018-5-19 19:4:48.274 DEBUG [main] >> app.root = E:/eclipse-workspace/maven/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/nutzbook
2018-5-19 19:4:48.274 INFO [main] !!!Your application without @IocBy supporting
2018-5-19 19:4:48.289 INFO [main] Build URL mapping by org.nutz.mvc.impl.UrlMappingImpl ...
2018-5-19 19:4:48.289 DEBUG [main] @Views(DefaultViewMaker.class)
2018-5-19 19:4:48.321 DEBUG [main] @ChainBy(org.nutz.mvc.impl.NutActionChainMaker)
2018-5-19 19:4:48.336 DEBUG [main] module class location 'file:/E:/eclipse-workspace/maven/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/nutzbook/WEB-INF/lib/nutz-1.r.60.jar'
2018-5-19 19:4:48.383 DEBUG [main]  > scan 'org.nutz'
2018-5-19 19:4:50.889 DEBUG [main] Found 1170 resource by src( org/nutz/ ) , regex( ^.+[.]class$ )
18-05-19 19:04:52.017 WARN [main] None module classes found!!!
18-05-19 19:04:52.026 WARN [main] None @At found in any modules class!!
五月 19, 2018 7:04:52 下午 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler ["http-nio-8080"]
2018-5-19 19:4:52.27 DEBUG [main] @Localization not define
2018-5-19 19:4:52.27 INFO [main] Nutz.Mvc[nutz] is up in 3753ms
五月 19, 2018 7:04:52 下午 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler ["ajp-nio-8009"]
五月 19, 2018 7:04:52 下午 org.apache.catalina.startup.Catalina start
信息: Server startup in 13945 ms
2018-5-19 19:4:52.596 DEBUG [http-nio-8080-exec-2] Search mapping for [GET] path=/ : NOT Action match
3 回复

按照例子的步骤,应该会自动创建表。然而Setup实现类的init方法都没有进入。
有配置@SetupBy(value = MainSetup.class)
结果是并没有启动这个方法,是教程的版本太旧了操作方式的问题吗。。。

首先,类名怎么写成这样了,改成MainModule啊,web.xml里面写了MainModule的全部路径径啊,怎么写成org.nutz.Nutz了?

额。抱歉老大,抽风了。。。问题已经解决,不知道类名什么时候写成nutzbook了。
现在已经好啦,一切正常!感谢~

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