使用Mybatis 首次連接資料庫出錯: FATAL [main] Main - getAssociatedStylesheets failed
原始碼下載自:https://how2j.cn/k/mybatis/mybatis-tutorial/1087.html#nowhere
請大神幫忙看看是啥情況哈

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<typeAliases>
<package name="com.how2java.pojo"/>
</typeAliases>
<environments default="development">
<environment id="development">
<transactionManager type="JDBC"/>
<dataSource type="POOLED">
<property name="driver" value="https://bbs.csdn.net/topics/com.mysql.jdbc.Driver"/>
<property name="url" value="https://bbs.csdn.net/topics/jdbc:mysql://127.0.0.1:3306/how2java?characterEncoding=UTF-8"/>
<property name="username" value="https://bbs.csdn.net/topics/root"/>
<property name="password" value="https://bbs.csdn.net/topics/963852"/>
</dataSource>
</environment>
</environments>
<mappers>
<mapper resource="com/how2java/pojo/Category.xml"/>
</mappers>
</configuration>
使用Mybatis 首次連接資料庫出錯: FATAL [main] Main - getAssociatedStylesheets failed
原始碼下載自:https://how2j.cn/k/mybatis/mybatis-tutorial/1087.html#nowhere
請大神幫忙看看是啥情況哈
uj5u.com熱心網友回復:
Category.xml的內容
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.how2java.pojo">
<select id="listCategory" resultType="Category">
select * from category_
</select>
</mapper>
uj5u.com熱心網友回復:
Category.java的內容
package com.how2java;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import com.how2java.pojo.Category;
public class TestMybatis {
public static void main(String[] args) throws IOException {
String resource = "mybatis-config.xml";
InputStream inputStream = Resources.getResourceAsStream(resource);
SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
SqlSession session=sqlSessionFactory.openSession();
List<Category> cs=session.selectList("listCategory");
for (Category c : cs) {
System.out.println(c.getName());
}
}
}
uj5u.com熱心網友回復:
貼完整的錯誤資訊uj5u.com熱心網友回復:
很多鏈接mysql資料庫的問題都是版本的問題,因為很多學習資料都是老版本的是mysql5.0的
你先確定一下你的mysql資料庫的版本是否是5.0,現版本mysql8.0的驅動程式和連接陳述句都是不一樣的。
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/49433.html
標籤:Web 開發
