您当前的位置: 首页 >  hibernate

宝哥大数据

暂无认证

  • 1浏览

    0关注

    1029博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

cms04---basic-hibernate03--BaseDao测试

宝哥大数据 发布时间:2017-10-29 18:43:41 ,浏览量:1

为了测试类不会打包, 将测试类放到src/test/java. 1.1、测试实体    使用Entiry注解使实体类为Hibernate所管理。

这里写图片描述

2、测试 问题1:MySQL在高版本需要指明是否进行SSL连接问题

Sun Oct 29 20:40:43 GMT+08:00 2017 WARN: 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.
解决方案:在url后加上 &useSSL=true
    public static Connection getConnection() throws SQLException {
        Connection con = null;
        //加上userSSL=true, 解决高版本是否连接SSL
        con = DriverManager.getConnection("jdbc:mysql://localhost:3307/cms_test?serverTimezone=UTC&useSSL=true", 
                "root", "root");
        return con;
    }
问题2:beans.xml的配置jdbc时,url后添加参数
Caused by: org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 23 in XML document from class path resource [beans.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 23; columnNumber: 93; 对实体 "useSSL" 的引用必须以 ';' 分隔符结尾。
解决方案:将参数删除。

改为
            
关注
打赏
1587549273
查看更多评论
0.0475s