NutzCN Logo
问答 拉下的新代码在启动的时候会运行以前的生成的model,为什么两个不关联的项目会弄在一起
发布于 11天前 作者 qq_856b85c9 60 次浏览 复制 上一个帖子 下一个帖子
标签:

这个cai_activity是很早以前键的一个表,而这次这个项目是我刚刚拉下来的,这为什么会关联在一起

严重: something happen!!
org.nutz.ioc.IocException: IocBean[dubboRpcCmsMainLauncher] throw Exception when creating
	at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:152)
	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:209)
	at org.nutz.boot.NbApp.run(NbApp.java:178)
	at cn.wizzer.app.cms.commons.core.DubboRpcCmsMainLauncher.main(DubboRpcCmsMainLauncher.java:50)
Caused by: org.nutz.dao.DaoException: !Nutz SQL Error: 'SELECT * FROM cai_activity  ORDER BY id DESC   LIMIT 0, 1 '
PreparedStatement: 
'SELECT * FROM cai_activity  ORDER BY id DESC   LIMIT 0, 1 '
CaseMessage=Table 'cai.cai_activity' doesn't exist
	at org.nutz.dao.impl.sql.run.NutDaoExecutor.exec(NutDaoExecutor.java:104)
	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.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.NutDao.query(NutDao.java:520)
	at org.nutz.dao.impl.NutDao.query(NutDao.java:510)
	at cn.wizzer.app.cms.commons.core.DubboRpcCmsMainLauncher.initRedisIg(DubboRpcCmsMainLauncher.java:85)
	at cn.wizzer.app.cms.commons.core.DubboRpcCmsMainLauncher.init(DubboRpcCmsMainLauncher.java:64)
	at cn.wizzer.app.cms.commons.core.DubboRpcCmsMainLauncher$FM$init$cff301be46c87e2fbea60f4ef344bacb.invoke(DubboRpcCmsMainLauncher.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)
	... 6 more
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'cai.cai_activity' doesn't exist
	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.executeQuery(StatementImpl.java:1381)
	at com.alibaba.druid.filter.FilterChainImpl.statement_executeQuery(FilterChainImpl.java:2831)
	at com.alibaba.druid.filter.FilterAdapter.statement_executeQuery(FilterAdapter.java:2503)
	at com.alibaba.druid.filter.FilterEventAdapter.statement_executeQuery(FilterEventAdapter.java:302)
	at com.alibaba.druid.filter.FilterChainImpl.statement_executeQuery(FilterChainImpl.java:2828)
	at com.alibaba.druid.proxy.jdbc.StatementProxyImpl.executeQuery(StatementProxyImpl.java:221)
	at com.alibaba.druid.pool.DruidPooledStatement.executeQuery(DruidPooledStatement.java:291)
	at org.nutz.dao.impl.sql.run.NutDaoExecutor._runSelect(NutDaoExecutor.java:246)
	at org.nutz.dao.impl.sql.run.NutDaoExecutor.exec(NutDaoExecutor.java:53)
	... 26 more

十月 10, 2018 5:47:02 下午 org.nutz.ioc.impl.NutIoc depose
信息: org.nutz.ioc.impl.NutIoc@2031377754 is closing. startup date [18-10-10 17:46:58.055]
十月 10, 2018 5:47:02 下午 org.apache.curator.framework.imps.CuratorFrameworkImpl backgroundOperationsLoop
信息: backgroundOperationsLoop exiting
十月 10, 2018 5:47:02 下午 org.apache.zookeeper.ZooKeeper close
信息: Session: 0x10000227bd20029 closed
十月 10, 2018 5:47:02 下午 org.apache.zookeeper.ClientCnxn$EventThread run
信息: EventThread shut down for session: 0x10000227bd20029
十月 10, 2018 5:47:02 下午 com.alibaba.druid.pool.DruidDataSource close
信息: {dataSource-1} closed
十月 10, 2018 5:47:02 下午 org.nutz.ioc.impl.NutIoc depose
信息: org.nutz.ioc.impl.NutIoc@2031377754 is deposed. startup date [18-10-10 17:46:58.055]

6 回复

某个pojo写了这个表名,或者是某个自定义sql

DubboRpcCmsMainLauncher.java:85

这个我还真没有动过这个,这个拉下来过就没有动过这个

package cn.wizzer.app.cms.commons.core;

import cn.wizzer.app.cms.commons.ig.RedisIdGenerator;
import org.nutz.boot.NbApp;
import org.nutz.dao.Cnd;
import org.nutz.dao.Dao;
import org.nutz.dao.Sqls;
import org.nutz.dao.entity.Record;
import org.nutz.dao.pager.Pager;
import org.nutz.dao.sql.Sql;
import org.nutz.dao.util.Daos;
import org.nutz.el.opt.custom.CustomMake;
import org.nutz.integration.jedis.JedisAgent;
import org.nutz.ioc.Ioc;
import org.nutz.ioc.impl.PropertiesProxy;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.Mirror;
import org.nutz.lang.Strings;
import org.nutz.log.Log;
import org.nutz.log.Logs;
import org.nutz.mvc.annotation.Modules;
import redis.clients.jedis.Jedis;

import java.sql.Driver;
import java.sql.DriverManager;
import java.util.Enumeration;
import java.util.List;
import java.util.regex.Pattern;

/**
 * Created by wizzer on 2018/3/17.
 */
@IocBean(create = "init", depose = "depose")
@Modules(packages = "cn.wizzer")
public class DubboRpcCmsMainLauncher {
    private static final Log log = Logs.get();
    @Inject("refer:$ioc")
    private Ioc ioc;
    @Inject
    private Dao dao;
    @Inject
    private PropertiesProxy conf;
    @Inject
    private JedisAgent jedisAgent;

    public static void main(String[] args) throws Exception {
        NbApp nb = new NbApp().setArgs(args).setPrintProcDoc(true);
        nb.getAppContext().setMainPackage("cn.wizzer");
        nb.run();
    }

    public void init() {
        //注册主键生成器
        CustomMake.me().register("ig", ioc.get(RedisIdGenerator.class));
        //通过POJO类创建表结构
        try {
            Daos.createTablesInPackage(dao, "cn.wizzer.app.cms", false);
            //通过POJO类修改表结构
            //Daos.migration(dao, "cn.wizzer.app.cms", true, false);
        } catch (Exception e) {
        }
        //初始化主键值到redis
        initRedisIg();
    }

    /**
     * 当项目启动的时候把表主键加载到redis缓存中
     */
    private void initRedisIg() {
        long a = System.currentTimeMillis();
        try (Jedis jedis = jedisAgent.getResource()) {
            Sql sql;
            if ("mysql".equalsIgnoreCase(dao.getJdbcExpert().getDatabaseType())) {
                sql = Sqls.create("SELECT table_name FROM information_schema.columns WHERE table_schema='" + conf.get("ig.db.name", "") + "' AND column_name='id'");
            } else {
                //oracle mssql该怎么写呢,等你来添加...
                log.info("wait for you ...");
                return;
            }
            sql.setCallback(Sqls.callback.strs());
            dao.execute(sql);
            List<String> tableNameList = sql.getList(String.class);
            for (String tableName : tableNameList) {
                List<Record> list = dao.query(tableName, Cnd.NEW().desc("id"), new Pager().setPageSize(1).setPageNumber(1));
                if (list.size() > 0) {
                    String id = list.get(0).getString("id");
                    if (Strings.isMatch(Pattern.compile("^.*[\\d]{16}$"), id)) {
                        String ym = id.substring(id.length() - 16, id.length() - 10);
                        if (Strings.isBlank(jedis.get("nutzwk:ig:" + tableName.toUpperCase() + ym))) {
                            jedis.set("nutzwk:ig:" + tableName.toUpperCase() + ym, String.valueOf(Long.valueOf(id.substring(id.length() - 10, id.length()))));
                        }
                    }
                }
            }
        }
        long b = System.currentTimeMillis();
        log.info("init redis ig time::" + (b - a) + "ms");
    }

    public void depose() {
        // 非mysql数据库,或多webapp共享mysql驱动的话,以下语句删掉
        try {
            Mirror.me(Class.forName("com.mysql.jdbc.AbandonedConnectionCleanupThread")).invoke(null, "shutdown");
        } catch (Throwable e) {
        }
        // 解决com.alibaba.druid.proxy.DruidDriver和com.mysql.jdbc.Driver在reload时报warning的问题
        // 多webapp共享mysql驱动的话,以下语句删掉
        Enumeration<Driver> en = DriverManager.getDrivers();
        while (en.hasMoreElements()) {
            try {
                Driver driver = en.nextElement();
                String className = driver.getClass().getName();
                log.debug("deregisterDriver: " + className);
                DriverManager.deregisterDriver(driver);
            } catch (Exception e) {
            }
        }
    }
}

执行过mvn install没?

如果group id一样,不同项目会冲突

确实执行过,那这样的话怎么修改,清空maven里面的上一个项目的内容?

或者改一下group id咯,pom.xml里面

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