项目错误笔记

1、MySQL5.7 The server time zone value 异常处理

错误描述:

### Error updating database.  Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (The server time zone value '�й���׼ʱ��' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support.)
### Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (The server time zone value '�й���׼ʱ��' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support.)
at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)
at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:200)
at org.apache.ibatis.session.defaults.DefaultSqlSession.insert(DefaultSqlSession.java:185)
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)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:433)
... 58 more
Caused by: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (The server time zone value '�й���׼ʱ��' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support.)
at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:80)
at org.mybatis.spring.transaction.SpringManagedTransaction.openConnection(SpringManagedTransaction.java:82)
at org.mybatis.spring.transaction.SpringManagedTransaction.getConnection(SpringManagedTransaction.java:68)
at org.apache.ibatis.executor.BaseExecutor.getConnection(BaseExecutor.java:336)
at org.apache.ibatis.executor.SimpleExecutor.prepareStatement(SimpleExecutor.java:84)
at org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:49)
at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:117)
at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:76)
at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:198)
... 64 more
Caused by: org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (The server time zone value '�й���׼ʱ��' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support.)
at org.apache.commons.dbcp.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:1549)
at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1388)
at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044)
at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:111)
at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:77)
... 72 more
Caused by: java.sql.SQLException: The server time zone value '�й���׼ʱ��' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support.
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:545)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:513)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:505)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:479)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:489)
at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:69)
at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:1606)
at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:633)
at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:347)
at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:219)
at org.apache.commons.dbcp.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:38)
at org.apache.commons.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:582)
at org.apache.commons.dbcp.BasicDataSource.validateConnectionFactory(BasicDataSource.java:1556)
at org.apache.commons.dbcp.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:1545)
... 76 more
Caused by: com.mysql.cj.core.exceptions.InvalidConnectionAttributeException: The server time zone value '�й���׼ʱ��' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support.
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.cj.core.exceptions.ExceptionFactory.createException(ExceptionFactory.java:54)
at com.mysql.cj.core.exceptions.ExceptionFactory.createException(ExceptionFactory.java:73)
at com.mysql.cj.jdbc.util.TimeUtil.getCanonicalTimezone(TimeUtil.java:118)
at com.mysql.cj.mysqla.MysqlaSession.configureTimezone(MysqlaSession.java:293)
at com.mysql.cj.jdbc.ConnectionImpl.initializePropsFromServer(ConnectionImpl.java:2399)
at com.mysql.cj.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:1739)
at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:1596)

... 83 more

解决方案:数据库连接url后面加 serverTimezone=GMT

                可以正常插入,但是插入的时间会差8个小时,解决办法:改为serverTimezone=GMT%2B8

如下:

jdbc.url=jdbc:mysql://localhost:3306/lwb?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8

 

2、Java连接Mysql数据库警告:Establishing SSL connection without server's identity verification is not recommend

mysql出现如下告警:

Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.

解决方案:

 

在mysql连接字符串url中加入ssl=true或者false即可,如下所示。

url=jdbc:mysql://127.0.0.1:3306/lwb?characterEncoding=utf8&useSSL=true

 

3、搭建SSM项目时,出现java.lang.IllegalAccessError: org.apache.commons.dbcp.DelegatingPreparedStatement.isClosed()

解决方案:mybatis版本太高,导致

4、CXF报错

E:\jdk1.8\jdk\bin\java "-javaagent:E:\idea2017\IntelliJ IDEA 2017.2.6\lib\idea_rt.jar=3985:E:\idea2017\IntelliJ IDEA 2017.2.6\bin" -Dfile.encoding=UTF-8 -classpath E:\jdk1.8\jdk\jre\lib\charsets.jar;E:\jdk1.8\jdk\jre\lib\deploy.jar;E:\jdk1.8\jdk\jre\lib\ext\access-bridge-64.jar;E:\jdk1.8\jdk\jre\lib\ext\cldrdata.jar;E:\jdk1.8\jdk\jre\lib\ext\dnsns.jar;E:\jdk1.8\jdk\jre\lib\ext\jaccess.jar;E:\jdk1.8\jdk\jre\lib\ext\jfxrt.jar;E:\jdk1.8\jdk\jre\lib\ext\localedata.jar;E:\jdk1.8\jdk\jre\lib\ext\nashorn.jar;E:\jdk1.8\jdk\jre\lib\ext\sunec.jar;E:\jdk1.8\jdk\jre\lib\ext\sunjce_provider.jar;E:\jdk1.8\jdk\jre\lib\ext\sunmscapi.jar;E:\jdk1.8\jdk\jre\lib\ext\sunpkcs11.jar;E:\jdk1.8\jdk\jre\lib\ext\zipfs.jar;E:\jdk1.8\jdk\jre\lib\javaws.jar;E:\jdk1.8\jdk\jre\lib\jce.jar;E:\jdk1.8\jdk\jre\lib\jfr.jar;E:\jdk1.8\jdk\jre\lib\jfxswt.jar;E:\jdk1.8\jdk\jre\lib\jsse.jar;E:\jdk1.8\jdk\jre\lib\management-agent.jar;E:\jdk1.8\jdk\jre\lib\plugin.jar;E:\jdk1.8\jdk\jre\lib\resources.jar;E:\jdk1.8\jdk\jre\lib\rt.jar;G:\laiwenbo\java\idea\lwb\ws\classes;G:\laiwenbo\java\idea\lwb\ws\lib\asm-5.2.jar;G:\laiwenbo\java\idea\lwb\ws\lib\neethi-3.1.1.jar;G:\laiwenbo\java\idea\lwb\ws\lib\wsdl4j-1.6.3.jar;G:\laiwenbo\java\idea\lwb\ws\lib\cxf-core-3.2.4.jar;G:\laiwenbo\java\idea\lwb\ws\lib\stax2-api-3.1.4.jar;G:\laiwenbo\java\idea\lwb\ws\lib\slf4j-api-1.7.25.jar;G:\laiwenbo\java\idea\lwb\ws\lib\cxf-rt-wsdl-3.2.4.jar;G:\laiwenbo\java\idea\lwb\ws\lib\woodstox-core-5.0.3.jar;G:\laiwenbo\java\idea\lwb\ws\lib\cxf-rt-ws-addr-3.2.4.jar;G:\laiwenbo\java\idea\lwb\ws\lib\wss4j-bindings-2.2.1.jar;G:\laiwenbo\java\idea\lwb\ws\lib\xmlschema-core-2.2.3.jar;G:\laiwenbo\java\idea\lwb\ws\lib\cxf-rt-bindings-soap-3.2.4.jar;G:\laiwenbo\java\idea\lwb\ws\lib\cxf-rt-frontend-jaxrs-3.2.4.jar;G:\laiwenbo\java\idea\lwb\ws\lib\cxf-rt-frontend-jaxws-3.2.4.jar;G:\laiwenbo\java\idea\lwb\ws\lib\cxf-rt-transports-udp-3.2.4.jar;G:\laiwenbo\java\idea\lwb\ws\lib\cxf-rt-frontend-simple-3.2.4.jar;G:\laiwenbo\java\idea\lwb\ws\lib\cxf-rt-transports-http-3.2.4.jar;G:\laiwenbo\java\idea\lwb\ws\lib\cxf-rt-databinding-jaxb-3.2.4.jar cn.laiwenbo.ws.cxf.WeatherClient
七月 18, 2018 5:31:23 下午 org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean buildServiceFromClass
信息: Creating Service {http://cxf.ws.laiwenbo.cn/}IWeatherServiceService from class cn.laiwenbo.ws.cxf.IWeatherService
七月 18, 2018 5:31:23 下午 org.apache.cxf.transport.http.HTTPTransportFactory getDestination
严重: Cannot find any registered HttpDestinationFactory from the Bus.
Exception in thread "main" org.apache.cxf.service.factory.ServiceConstructionException
    at org.apache.cxf.frontend.ServerFactoryBean.create(ServerFactoryBean.java:197)
    at org.apache.cxf.jaxws.JaxWsServerFactoryBean.create(JaxWsServerFactoryBean.java:211)
    at cn.laiwenbo.ws.cxf.WeatherClient.main(WeatherClient.java:23)
Caused by: java.io.IOException: Cannot find any registered HttpDestinationFactory from the Bus.
    at org.apache.cxf.transport.http.HTTPTransportFactory.getDestination(HTTPTransportFactory.java:276)
    at org.apache.cxf.binding.soap.SoapTransportFactory.getDestination(SoapTransportFactory.java:135)
    at org.apache.cxf.endpoint.ServerImpl.initDestination(ServerImpl.java:84)
    at org.apache.cxf.endpoint.ServerImpl.<init>(ServerImpl.java:63)
    at org.apache.cxf.frontend.ServerFactoryBean.create(ServerFactoryBean.java:182)
    ... 2 more

Process finished with exit code 1


解决方案:

加入jetty服务器相关的jar包,如果是发布在tomcat服务器上,则不会发生这样的问题。

猜你喜欢

转载自blog.csdn.net/u013441805/article/details/80455146