我正在使用Spring Boot 1.5.9。
是否可以打开/关闭@Controller
和@Services
?
诸如@ConditionalOnProperty
,@Conditional
之类的豆子。
@ConditionalController // <--- something like this
@RestController
public class PingController {
@Value("${version}")
private String version;
@RequestMapping(value = CoreHttpPathStore.PING,method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public ResponseEntity<Map<String,Object>> ping() throws Exception {
HashMap<String,Object> map = new HashMap<>();
map.put("message","Welcome to our API");
map.put("date",new Date());
map.put("version",version);
map.put("status",HttpStatus.OK);
return new ResponseEntity<>(map,HttpStatus.OK);
}
}
然后使用一些配置bean进行加载。
预先感谢