public class GetSqlSession { public static SqlSession createSqlSession() { SqlSessionFactory SqlSessionFactory = null; InputStream input = null; SqlSession session = null; try { String resource = "mybatis-config.xml"; input = Resources.getResourceAsStream(resource); sqlSessionFactory = new SqlSessionFactoryBuilder().build(input); session = sqlSessionFactory.openSession(); return session; } catch (IOException e) { e.printStackTrace(); return null; } } public static void main(String[] args) { System.out.println(createSqlSession()); } }报错
时间: 2024-01-25 10:02:54 浏览: 136
在你提供的代码中,有一个拼写错误,将 `SqlSessionFactory` 的首字母大小写写错了,导致无法编译通过。正确的写法应该是:
```
public class GetSqlSession {
public static SqlSession createSqlSession() {
SqlSessionFactory sqlSessionFactory = null;
InputStream input = null;
SqlSession session = null;
try {
String resource = "mybatis-config.xml";
input = Resources.getResourceAsStream(resource);
sqlSessionFactory = new SqlSessionFactoryBuilder().build(input);
session = sqlSessionFactory.openSession();
return session;
}
catch (IOException e) {
e.printStackTrace();
return null;
}
}
public static void main(String[] args) {
System.out.println(createSqlSession());
}
}
```
请注意,这里的修改只是修正了拼写错误,并没有看到完整的报错信息,因此如果您需要更详细的帮助,请提供完整的报错信息。
阅读全文