1、创建配置文件(application.properties)
spring.activemq.broker-url=tcp://localhost:61616
spring.activemq.user=admin
spring.activemq.password=admin
spring.activemq.in-memory=true
spring.activemq.pool.enabled=false
2、创建测试类(MyController.java)
package com.jeff.controller;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class MyController {
@Value("${spring.activemq.user}")
private String user;
@RequestMapping("myTest")
public String myTest() {
System.out.println("user的值:" + user);
return "success";
}
}
3、打开浏览器访问 http://localhost:8080/myTest,控制台输出结果