我是Spring/Spring Boot的新手,所以请原谅我所要求的是微不足道的.
我创建了Spring Boot应用程序,它暴露了REST端点:
package com.atomic.contentguard;
...
@Controller
@RequestMapping("/rest")
public class AcgController {
@RequestMapping(value="/acg-status",method=RequestMethod.GET)
@ResponseBody
public String getStatus(){
return "Hi there!";
}
}
Run Code Online (Sandbox Code Playgroud)
当您将其作为独立的Spring Boot应用程序运行时,一切正常,端点可以通过访问http:// localhost:8080/rest/acg-status来测试.
我想要实现的是"将它"带入另一个应用程序,该应用程序将我的应用程序作为pom.xml中的依赖项包括在内,期望这个REST端点显示在其中.
到目前为止我所做的是将它包含在另一个项目pom.xml中:
</dependencies>
...
<dependency>
<groupId>com.atomic</groupId>
<artifactId>contentguard</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
Run Code Online (Sandbox Code Playgroud)
然后将其包含在配置文件的其他应用程序@ComponentScan部分中:
@Configuration
@EnableWebMvc
@ComponentScan(basePackages = {"com.atomic.contentguard"})
public class EnvInfoWebConfig extends WebMvcConfigurerAdapter {
}
Run Code Online (Sandbox Code Playgroud)
但是,当您运行目标应用程序时,它不会显示:
No mapping found for HTTP request with URI [/other-application-context/rest/acg-status] in DispatcherServlet with name 'envinfo-dispatcher'
Run Code Online (Sandbox Code Playgroud)
我错过了什么/做错了什么?