1解决方式
在类上在加@Compent
@Component
@EnableBinding(Sink.class)
public class ReceiveMessageListenerController
@Value("${server.port}")
private String serverPort;
2静态属性使用set
@Component
@EnableBinding(Sink.class)
public class ReceiveMessageListenerController {
private static String serverPort;
@Value("${server.port}")
public void setServerPort(String serverPort) {
this.serverPort = serverPort;
}
3通过@Autowired
@Autowired
private ReceiveMessageListenerController ( @Value("${server.port}")String serverPort) {
this.serverPort= serverPort;
}