小编Har*_*hit的帖子

如何将rest控制器添加到spring boot库,并在另一个应用程序中使用它?

我正在开发一个库xyz.jar,需要添加一个具有如下映射的 UI 页面:

@RestController
public class LibCtrl {
    
    @EventListener(ApplicationReadyEvent.class)
    @RequestMapping("/updateDomainList")
    String updateDomainList() {
        return "we can call a controller from another jar like this";
    }
}
Run Code Online (Sandbox Code Playgroud)

然后需要在我的主 springboot 应用程序中调用,myMainApplication.war所以当我调用

http://localhost/myMainApplication/updateDomainList

我应该看看

we can call controller from another jar like this
Run Code Online (Sandbox Code Playgroud)

在浏览器上。

如何才能实现这一点呢?@Component也不适合我。一旦开始起作用,是否@AutowiredJdbcTemplate起作用?

spring-boot

7
推荐指数
1
解决办法
3370
查看次数

标签 统计

spring-boot ×1