下载nutz工程搭建环境测试过程中的几个小问题

这几天,经同事介绍想学习一下Nutz,至于有什么好处加为什么学,自已百度!

按照nutz手册 下载了nutz工程源码,一步一步配置,有几个地方需要注意一下!
2. 创建连接配置文件
在 Eclipse 项目里,增加一个新的 source folder (这个很重要):右击项目 > New >Source Folder
a.随便给这个 Folder 起个名字,比如 properties
b.然后在里面创建一个文本文件 nutz-test.properties
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
at org.nutz.Nutzs.loadProperties(Nutzs.java:41)
at org.nutz.Nutzs.checkProperties(Nutzs.java:32)
at org.nutz.dao.test.DaoCase.setUp(DaoCase.java:20)
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:498)
PreparedStatement:
'INSERT INTO t_goods(name,thumb) VALUES(?,?) '
CaseMessage=Packet for query is too large (3695 > 2048). You can change this value on the server by setting the max_allowed_packet' variable.
at org.nutz.dao.impl.sql.run.NutDaoExecutor.exec(NutDaoExecutor.java:102)
at org.nutz.dao.DaoInterceptorChain.doChain(DaoInterceptorChain.java:66)
at org.nutz.dao.impl.interceptor.SayHiDaoInterceptor.filter(SayHiDaoInterceptor.java:16)
at org.nutz.dao.DaoInterceptorChain.doChain(DaoInterceptorChain.java:64)
at org.nutz.dao.impl.interceptor.DaoTimeInterceptor.filter(DaoTimeInterceptor.java:23)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Caused by: com.mysql.jdbc.PacketTooBigException: Packet for query is too large (3695 > 2048). You can change this value on the server by setting the max_allowed_packet' variable.
at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3675)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2506)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2677)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2549)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1861)
at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:1192)
at com.alibaba.druid.pool.DruidPooledPreparedStatement.execute(DruidPooledPreparedStatement.java:493)
at org.nutz.dao.impl.sql.run.NutDaoExecutor._runPreparedStatement(NutDaoExecutor.java:308)
at org.nutz.dao.impl.sql.run.NutDaoExecutor.exec(NutDaoExecutor.java:90)
... 74 more
上面已经提示解决方法了,设置max_allowed_packet属性,主要有两种方法:
org.nutz.dao.DaoException: !Nutz SQL Error: 'CREATE TABLE dao_country(
id INT(32) AUTO_INCREMENT,
name VARCHAR(128) UNIQUE NOT NULL,
detail VARCHAR(128),
PRIMARY KEY (id)
) ENGINE=InnoDB CHARSET=utf8'
PreparedStatement:
'CREATE TABLE dao_country(
id INT(32) AUTO_INCREMENT,
name VARCHAR(128) UNIQUE NOT NULL,
detail VARCHAR(128),
PRIMARY KEY (id)
) ENGINE=InnoDB CHARSET=utf8'
CaseMessage=Table 'zzhtest.dao_country' doesn't exist
at org.nutz.dao.impl.sql.run.NutDaoExecutor.exec(NutDaoExecutor.java:102)
at org.nutz.dao.DaoInterceptorChain.doChain(DaoInterceptorChain.java:66)
at org.nutz.dao.impl.interceptor.SayHiDaoInterceptor.filter(SayHiDaoInterceptor.java:16)
·······························

运行 JUnit 测试

一、找不到nutz-test.properties Not FOUND!!!

请注意,一定要叫这个名字,否则运行测试一定是不过的,详细原因请看 /test/org/nutz/Nutzs.java 的源代码

我当时的操作是:右击项目 > New > Folder

打开test/org/nutz/TestAll.java ,然后用 JUnit 运行,结果报错

log4j:WARN No appenders could be found for logger (org.nutz.resource.Scans).

java.lang.RuntimeException: nutz-test.properties Not FOUND!!! tmpl.nutz-test.properties is a example.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

二、数据库保存出错

org.nutz.dao.DaoException: !Nutz SQL Error: 'INSERT INTO t_goods(name,thumb) VALUES('AAA','*byte[len=1820]') '

1、window环境下修改my.ini,修改max_allowed_packe=20M

2、运行mysql命令,

mysql>set global max_allowed_packet = 2*1024*1024*10

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

三、删除

我擦,这是怎么个情况!是不是可能在创建数据库表的过程中出现的问题,我删除zzhtest数据库,但是在删除数据库过程中,又出现了一个异常,

ERROR 1010 (HY000): Error dropping database(can't rmdir './zzhtest',errno:17)

找到MySQL安装目录下的Data文件夹,删除zzhtest文件夹下文件,就能删掉了;

然后重新新建zzhtest数据库。

 

这一篇写的有点乱,这是我运行nutz测试时遇到的几个问题!

 

猜你喜欢

转载自zhangshufei8001.iteye.com/blog/2377243