sys dubbo.xml 将annotation package="cn.wizzer.app.sys"
修改
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
<dubbo:application name="wk-nb-sys-service" />
<dubbo:registry address="zookeeper://127.0.0.1:2181" />
<dubbo:protocol name="dubbo" port="55010" />
<dubbo:annotation package="cn.wizzer.app" />
</beans>
然后再app下写实体类
@Table("company")
public class Company extends BaseModel implements Serializable {
private static final long serialVersionUID = 1L;
@Column
@Name
@Comment("ID")
@ColDefine(type = ColType.VARCHAR, width = 32)
@Prev(els = {@EL("uuid()")})
private String id;
@Column
@Comment("公司名")
@ColDefine(type = ColType.VARCHAR, width = 56)
private String name;
@Column
@Comment("公司地址")
@ColDefine(type = ColType.VARCHAR, width = 108)
private String address;
@Column
@Comment("联系电话")
@ColDefine(type = ColType.VARCHAR, width = 108)
private String phone;
@Column
@Comment("审核状态")
@ColDefine(type = ColType.INT)
private Integer check;
再修改init方法
public void init() {
//通过POJO类创建表结构
try {
Daos.createTablesInPackage(dao, "cn.wizzer.app", false);
} catch (Exception e) {
log.error(e.getMessage(), e);
}
try {
if (log.isDebugEnabled()) {
//通过POJO类修改表结构
Daos.migration(dao, "cn.wizzer.app", true, false);
}
} catch (Exception e) {
log.error(e.getMessage(), e);
}
启动报错
[DEBUG] 10:24:48.117 org.nutz.plugins.cache.dao.CachedNutDaoExecutor.exec(CachedNutDaoExecutor.java:110) - Exception when parser SQL sql, skip cache detect!! SQL=CREATE TABLE company(
id VARCHAR(32) COMMENT 'ID',
name VARCHAR(56) COMMENT '公司名',
address VARCHAR(108) COMMENT '公司地址',
phone VARCHAR(108) COMMENT '联系电话',
check INT(32) COMMENT '审核状态',
opBy VARCHAR(32) COMMENT '操作人',
opAt BIGINT(36) COMMENT '操作时间',
delFlag BOOLEAN COMMENT '删除标记',
PRIMARY KEY (id)
) ENGINE=InnoDB CHARSET=utf8
[DEBUG] 10:24:48.117 org.nutz.dao.impl.sql.run.NutDaoExecutor.printSQL(NutDaoExecutor.java:388) - CREATE TABLE company(
id VARCHAR(32) COMMENT 'ID',
name VARCHAR(56) COMMENT '公司名',
address VARCHAR(108) COMMENT '公司地址',
phone VARCHAR(108) COMMENT '联系电话',
check INT(32) COMMENT '审核状态',
opBy VARCHAR(32) COMMENT '操作人',
opAt BIGINT(36) COMMENT '操作时间',
delFlag BOOLEAN COMMENT '删除标记',
PRIMARY KEY (id)
) ENGINE=InnoDB CHARSET=utf8
[DEBUG] 10:24:48.119 org.nutz.dao.impl.sql.run.NutDaoExecutor.exec(NutDaoExecutor.java:97) - SQLException
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INT(32) COMMENT '审核状态',
opBy VARCHAR(32) COMMENT '操作人',
opAt BIGIN' at line 6
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:425)
at com.mysql.jdbc.Util.getInstance(Util.java:408)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:944)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3976)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3912)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2530)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2683)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2482)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2440)
at com.mysql.jdbc.StatementImpl.executeInternal(StatementImpl.java:845)
at com.mysql.jdbc.StatementImpl.execute(StatementImpl.java:745)
at com.alibaba.druid.filter.FilterChainImpl.statement_execute(FilterChainImpl.java:2600)
at com.alibaba.druid.filter.FilterAdapter.statement_execute(FilterAdapter.java:2473)
at com.alibaba.druid.filter.FilterEventAdapter.statement_execute(FilterEventAdapter.java:188)
at com.alibaba.druid.filter.FilterChainImpl.statement_execute(FilterChainImpl.java:2598)
at com.alibaba.druid.proxy.jdbc.StatementProxyImpl.execute(StatementProxyImpl.java:147)
at com.alibaba.druid.pool.DruidPooledStatement.execute(DruidPooledStatement.java:558)
at org.nutz.dao.impl.sql.run.NutDaoExecutor._runStatement(NutDaoExecutor.java:357)
at org.nutz.dao.impl.sql.run.NutDaoExecutor.exec(NutDaoExecutor.java:60)
at org.nutz.dao.DaoInterceptorChain.doChain(DaoInterceptorChain.java:66)
at org.nutz.dao.impl.interceptor.DaoTimeInterceptor.filter(DaoTimeInterceptor.java:23)
at org.nutz.dao.DaoInterceptorChain.doChain(DaoInterceptorChain.java:64)
at org.nutz.dao.impl.interceptor.DaoLogInterceptor.filter(DaoLogInterceptor.java:22)
at org.nutz.dao.DaoInterceptorChain.doChain(DaoInterceptorChain.java:64)
at org.nutz.plugins.cache.dao.DaoCacheInterceptor._exec(DaoCacheInterceptor.java:28)
at org.nutz.plugins.cache.dao.CachedNutDaoExecutor.exec(CachedNutDaoExecutor.java:111)
at org.nutz.plugins.cache.dao.DaoCacheInterceptor.filter(DaoCacheInterceptor.java:18)
at org.nutz.dao.DaoInterceptorChain.doChain(DaoInterceptorChain.java:64)
at org.nutz.dao.DaoInterceptorChain.invoke(DaoInterceptorChain.java:139)
at org.nutz.dao.impl.sql.run.NutDaoRunner.runCallback(NutDaoRunner.java:159)
at org.nutz.dao.impl.sql.run.NutDaoRunner._runWithoutTransaction(NutDaoRunner.java:126)
at org.nutz.dao.impl.sql.run.NutDaoRunner._run(NutDaoRunner.java:93)
at org.nutz.dao.impl.sql.run.NutDaoRunner.run(NutDaoRunner.java:82)
at org.nutz.dao.impl.DaoSupport.run(DaoSupport.java:240)
at org.nutz.dao.impl.DaoSupport._exec(DaoSupport.java:252)
at org.nutz.dao.impl.DaoSupport.execute(DaoSupport.java:236)
at org.nutz.dao.impl.NutDao.execute(NutDao.java:1008)
at org.nutz.dao.impl.jdbc.mysql.MysqlJdbcExpert.createEntity(MysqlJdbcExpert.java:173)
at org.nutz.dao.impl.NutDao.create(NutDao.java:812)
at org.nutz.dao.util.Daos.createTables(Daos.java:524)
at org.nutz.dao.util.Daos.createTablesInPackage(Daos.java:443)
at cn.wizzer.app.sys.commons.core.DubboRpcSysMainLauncher.init(DubboRpcSysMainLauncher.java:46)
at cn.wizzer.app.sys.commons.core.DubboRpcSysMainLauncher$FM$init$cff301be46c87e2fbea60f4ef344bacb.invoke(DubboRpcSysMainLauncher.java)
at org.nutz.ioc.impl.ObjectMakerImpl$2.trigger(ObjectMakerImpl.java:180)
at org.nutz.ioc.weaver.DefaultWeaver.onCreate(DefaultWeaver.java:89)
at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:141)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:241)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:271)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:161)
at org.nutz.boot.NbApp.execute(NbApp.java:208)
at org.nutz.boot.NbApp.run(NbApp.java:177)
at cn.wizzer.app.sys.commons.core.DubboRpcSysMainLauncher.main(DubboRpcSysMainLauncher.java:40)