1. 程式人生 > >關於linux部署專案後的錯誤暴露

關於linux部署專案後的錯誤暴露

1、tomcat啟動後  某些表找不到錯誤:

INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during sca nning can i:46ove startup time and JSP compilation time. Exception in thread "SimpleAsyncTaskExecutor-1" org.springframework.jdbc.BadSqlGrammarException:
### Error querying database.Cause: com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: Table 'mantouweixin.PUB_GLOBALCONFIG' doesn't exist ### The error may involvecom.eazer.pub.dao.IPubGlobalconfigMapper.selectModelList-Inline ### The error occurred while setting parameters ### Cause: com.mysql.jdbc.exceptions.MySQLSyntaxErrorException:
Table 'mantouweixin.PUB_GLOBALCONFIG' doesn't exist ; bad SQL grammar []; nested exception is com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: Table 'mantouweixin.PUB_GLOBALCONFIG' doesn't exist at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:233)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72) at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:71) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:346) at com.sun.proxy.$Proxy15.selectList(Unknown Source) at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:196) at com.eazer.base.MyBatisDaoManager.selectModelList(MyBatisDaoManager.java:214) at com.eazer.pub.service.impl.PubGlobalconfigServiceImpl.load(PubGlobalconfigServiceImpl.java:109) at com.eazer.pub.service.impl.PubGlobalconfigServiceImpl.loadCache(PubGlobalconfigServiceImpl.java:86) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:319) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:196) at com.sun.proxy.$Proxy20.loadCache(Unknown Source) at com.eazer.pub.service.impl.PubGlobalContextCache$1.run(PubGlobalContextCache.java:254) at java.lang.Thread.run(Thread.java:748) Caused by: com.mysql.jdbc.exceptions.MySQLSyntaxErrorException:Table 'mantouweixin.PUB_GLOBALCONFIG' doesn't exist at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:936) Exception in thread "SimpleAsyncTaskExecutor-3"at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2985) at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1631) at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1723) at com.mysql.jdbc.Connection.execSQL(Connection.java:3283) at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1332) at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:882) at org.apache.commons.dbcp.DelegatingPreparedStatement.execute(DelegatingPreparedStatement.java:169) at org.apache.ibatis.executor.statement.PreparedStatementHandler.query(PreparedStatementHandler.java:39) at org.apache.ibatis.executor.statement.RoutingStatementHandler.query(RoutingStatementHandler.java:55) at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:41) at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:238) at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:112) at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:72) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.apache.ibatis.plugin.Invocation.proceed(Invocation.java:38) at com.eazer.base.page.ExecutorInterceptor.handAll(ExecutorInterceptor.java:158) at com.eazer.base.page.ExecutorInterceptor.intercept(ExecutorInterceptor.java:130) at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:68) at com.sun.proxy.$Proxy28.query(Unknown Source) at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:78) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:338) ... 14 more 事件前提是我的專案中Mapper檔案使用的sql語句都是大寫 上網搜尋發現 mysql配置檔案中 是有一個預設屬性的:lower_case_table_names 1) windows下mysql資料庫是預設表名不區分大小寫的, 引數值預設為1 , 所以windows環境下sql語句使用大小寫都無所謂 2) 在linux下引數值預設為0(區分大小寫) 3) 但是mysql建表後表名都是小寫 所以此時我的專案部署上去啟動後資料庫找不到這些大寫的表名 因此報錯 4) download下來mysql配置檔案:/etc/my.cnf 後重啟mysql :service mysqld restart 2、專案部署後操作資料發現中文亂碼問題
編輯了一個屬性 就亂碼了 1) 排除掉專案本身的和tomcat的配置檔案編碼屬性 找到是因為mysql配置檔案缺少自定義編碼配置 因為其預設是Latin1編碼 2) 編輯/etc/my.cnf : 圖中三個位置
編輯完上傳重啟就行了 最開始安裝mysql時我是選擇讓它預設安裝的 包括路徑之類的。mysql在執行時使用的配置檔案之一就是my.cnf。安裝完成後的my.cnf檔案裡面的屬性配置基本沒有 於是我去安裝路徑下 /usr/share/mysql 找的一個叫 my-large.cnf 的檔案 複製到 /etc下更名為my.cnf 再進行的後續操作。