下載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測試時遇到的幾個問題!


發佈了86 篇原創文章 · 獲贊 97 · 訪問量 76萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章