package com.example.bean; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.context.annotation.PropertySource; import org.springframework.stereotype.Component; @Component @PropertySource(value = "classpath:book.yml", ignoreResourceNotFound = true,encoding = "UTF-8" ) @ConfigurationProperties(prefix = "book")public class Book { @Value("${name}") private String name; @Value("${author}") private String author; @Value("${price}") private String price; public Book () {}; public Book(String name,String author,String price) { this.name = name; this.author = author; this.price = price; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getAuthor() { return author; } public void setAuthor(String author) { this.author = author; } public String getPrice() { return price; } public void setPrice(String price) { this.price = price; }; }
spring boot读取自定义配置文件时乱码解决办法
最新推荐文章于 2022-12-09 22:24:54 发布