202202-28 springboot如何使用@Value获取配置文件的值 使用@Value获取配置文件的值1、创建配置文件(application.properties)spring.activemq.broker-url=tcp://localhost:61616spring.activemq.user=adminspring.activemq.password=adminspring.activemq.in-memory=truespring.activemq.pool.enabled=false2、创建测试类(MyController.java)packagecom.jeff.controller;importorg.springframework.beans.factory.annotation.Value;importorg.springframework.web.bind.annotatio... 继续阅读 >
202011-11 SpringBoot 使用 @Value 注解读取配置文件给静态变量赋值 1、application.properties配置文件mail.username=xue@163.commail.password=xuemail.host=smtp.163.commail.smtp.auth=true2、给普通变量赋值,直接在变量上添加@Value注解importorg.springframework.beans.factory.annotation.Value;publicclassMailConfig{@Value("${mail.username}")privateStringusername;@Value("${mail.password}")privateStringpassword;@Value("${mail.host}")privateStringhost... 继续阅读 >