将SpringBoot应用程序打包为EAR并部署到本地TomEE 7实例。
部署后,将在TOMEE/my-app-api
从tOMEE / my-app-api / index.html
正确提供webapp文件夹中的静态index.html页面我有一个RestController
,其中一个GET端点映射到/api/country
当我尝试通过RestController
拨打TOMEE/my-app-api/api/country
时,我会收到404。
如果我从嵌入式Tomcat实例运行相同的应用程序并通过RestController
调用TOMCAT/api/country
,我会得到一个成功的回复。
为了让SpringBoot在这个上下文路径下托管,我还需要配置什么吗?
EAR Gradle任务
apply plugin: 'ear'
version = '1.0.0-SNAPSHOT'
ear {
archiveName = 'git rev-parse --short HEAD'.execute().text.trim() + "-$version" + '-service.ear'
baseName = 'git rev-parse --short HEAD'.execute().text.trim()
version= "-$version" + '-service'
deploymentDescriptor {
displayName = 'Service API'
webModule('service-api.war', 'service-api')
}
}
dependencies{
deploy project(path: ':service-api', configuration: 'archives')
deploy project(path: ':service-data', configuration: 'archives')
deploy project(path: ':service-rules', configuration: 'archives')
}
申请类
@SpringBootApplication
public class ServiceApplication extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(ServiceApplication.class);
}
public static void main(String[] args) {
SpringApplication.run(ServiceApplication.class, args);
}
}