Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
2.7k views
in Technique[技术] by (71.8m points)

spring - Set jpa utf-8 encoding in application.properties

This is a followup question to the following:

JPA utf-8 characters not persisted

The answer (https://stackoverflow.com/a/32574280) worked for me. However, I would like to save those configurations in my application.properties file separate from the url configuration. What would be the name of those configurations?

I've tried:

connection.useUnicode=true connection.characterEncoding=utf8

And then I set them in my Properties in my Configuration class:

properties.put("connection.useUnicode", env.getRequiredProperty("connection.useUnicode")); properties.put("connection.characterEncoding", env.getRequiredProperty("connection.characterEncoding"));

But it isn't working.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

if you are using spring boot, in application properties

spring.datasource.connectionProperties=useUnicode=true;characterEncoding=utf-8;

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...