读取文档时出现问题129_springboot读取配置文件的自定义内容时出现中文乱码
學習springboot時讀取配置文件自定義內容出現中文亂碼總結。
方法一:
Windowd→Preferences→General→Editors→Text Editors→Spelling里面的Encoding為UTF-8
方法二:
Windowd→Preferences→General→Content Types里面的Text→Java Properties File最下面的Default encoding為UTF–8
方法三:
下載PerportiesEditor插件Windowd→Preferences→General→Editors→Flie Associations里面設置*.properties文件使用Perporties File Editor為默認打開
方法四:
主配置文件application.properties點擊右鍵→Properties→Resource設置Text file encoding為UTF-8
方法五:
主配置文件編寫
banner.charset=UTF-8
server.tomcat.uri-encoding=UTF-8
spring.messages.encoding=UTF-8
spring.freemarker.charset=UTF-8
spring.http.encoding.charset=UTF-8
spring.http.encoding.forcr=true
spring.http.encoding.enabled=true
方法六:
設置@PropertySource的encoding為UTF-8
方法七:
將自定義內容從主配置文件中移動到自己建的配置文件中,并設置@PropertySource的讀取文件路徑
(如:
步驟1、application.properties配置文件中有自定義內容name=張三,將其刪除。
步驟2、創建一個新的配置文件springboot.properties,寫入自定義內容
步驟3、設置@PropertySource的讀取文件路徑為value="classpath:springboot.properties")
總結
以上是生活随笔為你收集整理的读取文档时出现问题129_springboot读取配置文件的自定义内容时出现中文乱码的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: php mysql简单留言本_php+m
- 下一篇: launch mysql_Mac Pro