1. 程式人生 > >spring boot那些年遇到的坑

spring boot那些年遇到的坑

坑1.通過@ConfigurationProperties註解無法獲取yml配置的值 

netty:
  port: 5000
  module-type: 0
@Component
@ConfigurationProperties(prefix = "netty")
public class NettyConfig {

    private int port;
    
    private int moduleType;

    public int getPort() {
        return port;
    }

    public void setPort(int port) {
        this.port = port;
    }

	public int getModuleType() {
		return moduleType;
	}

	public void setModuleType(int moduleType) {
		this.moduleType = moduleType;
	}
}