在配置文件中配置的值使用@Value注解为static变量赋值

    技术2025-03-04  32

    配置文件:

    netty: port:9095 url:127.0.0.1

    代码:

    private static String host; private static int port; @Value("${netty.url}") public void setHost(String host){ NettyClient.host = host; } @Value("${netty.port}") public void setHost(String port){ NettyClient.port = port; }
    Processed: 0.013, SQL: 9