- 确保将JDBC驱动程序设置为使用UTF-8:
jdbc:mysql://dbname?useUnipre=true&characterEncoding=utf-8
- 在中
persistence.xml
,设置hibernate连接字符集:
<property name="hibernate.connection.charSet" value="UTF-8"/>
如果
resources/import.sql文件是多行,请添加:
<property name="hibernate.hbm2ddl.import_files_sql_extractor" value="org.hibernate.tool.hbm2ddl.MultipleLinesSqlCommandExtractor" />
或对于Spring Boot,在
application.properties:
spring.jpa.properties.hibernate.connection.charSet=UTF-8spring.jpa.properties.hibernate.hbm2ddl.import_files_sql_extractor=org.hibernate.tool.hbm2ddl.MultipleLinesSqlCommandExtractor
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)