这样写的时候起作用:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
<?xml version= "1.0" encoding= "UTF-8" ?> <!DOCTYPE configuration "http://mybatis.org/dtd/mybatis-3-config.dtd" > <configuration> <typeAliases> <typeAlias type= "com.hc.entity.UserInfo" alias= "UserInfo" /> </typeAliases> <environments default = "development" > <environment id= "mysql" > <transactionManager type= "JDBC" /> <dataSource type= "POOLED" > <property name= "driver" value= "com.mysql.jdbc.Driver" /> <property name= "url" value= "jdbc:mysql://localhost:3306/db_mybatis" /> <property name= "username" value= "hhc" /> <property name= "password" value= "******" /> </dataSource> </environment> </environments> <mappers> <mapper resource= "com/hc/mapper/UserInfo.xml" /> </mappers> </configuration> |
这样写不起作用:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
jdbc.driverClass=com.mysql.jdbc.Driver jdbc.url=jdbc:mysql: //localhost:3306/db_mybatis jdbc.username=hc jdbc.password= 123456 <?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> <properties resource= "jdbc.properties" /> <typeAliases> <typeAlias type= "com.hc.entity.UserInfo" alias= "UserInfo" /> </typeAliases> <environments default = "development" > <environment id= "mysql" > <transactionManager type= "JDBC" ></transactionManager> <dataSource type= "POOLED" > <property name= "driver" value= "${jdbc.driverClass}" /> <property name= "url" value= "${jdbc.url}" /> <property name= "username" value= "${jdbc.username}" /> <property name= "password" value= "${jdbc.password}" /> </dataSource> </environment> </environments> <mappers> <mapper resource= "com/hc/mapper/userinfo.xml" /> </mappers> </configuration> |
解决方法:
1.在jdbc.properties鼠标右键Properties(属性),把ISO-8859-1更改为UTF-8
2.在整个项目鼠标右键,把ISO-8859-1更改为UTF-8 具体操作如下图
总结
以上所述是小编给大家介绍的mybatis 使用jdbc.properties文件设置不起作用的解决方法,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对服务器之家网站的支持!
原文链接:http://blog.csdn.net/qq_28061489/article/details/79239248