java - Liberty Core:未找到 Spring Boot 上下文根
问题描述
使用 Liberty Core 运行我的 Spring Boot 应用程序给了我这个错误并且没有记录任何错误!
所以我创建了一个基于 spring-boot-starter-web 的 pom 文件,并使用 starter 类排除了 tomcat:
@Configuration
@EnableAutoConfiguration
@SpringBootApplication
@ComponentScan(basePackages = { "com.a.b.c" }, lazyInit = true)
public class SpringBootApp extends SpringBootServletInitializer {
/**
* @param args main aguments
*/
public static void main(final String[] args) {
SpringApplication.run(SpringBootApp.class, args);
}
/*
* (non-Javadoc)
*
* @see org.springframework.boot.web.support.SpringBootServletInitializer#configure(org.springframework.boot.builder.
* SpringApplicationBuilder)
*/
@Override
protected SpringApplicationBuilder configure(final SpringApplicationBuilder builder) {
return builder.sources(SpringBootApp.class);
}
}
我的控制器:
@RestController
@RequestMapping("/api")
public class CustomerResource {
/**
* @param customerDTO
* @return
*/
@PostMapping("/customers")
public ResponseEntity<URI> addOrder(
@Valid @RequestBody final CustomerDTO customerDTO) {
final URI location = ServletUriComponentsBuilder.fromCurrentRequest()
.path("/{id}").buildAndExpand("id").toUri();
return ResponseEntity.created(location).build();
}
/**
* @param customerID
* @return
*/
@GetMapping("/customers/{customerID}")
public CustomerDTO getCustomer(@PathVariable final String customerID) {
return new CustomerDTO();
}
}
WS Liberty Code (85) 上的服务器 xml
<?xml version="1.0" encoding="UTF-8"?>
<server description="sa-57487">
<!-- Enable features -->
<featureManager>
<feature>jsp-2.2</feature>
<feature>ssl-1.0</feature>
<feature>jpa-2.0</feature>
<feature>jdbc-4.0</feature>
<feature>jndi-1.0</feature>
<feature>servlet-3.0</feature>
<feature>localConnector-1.0</feature>
<feature>restConnector-1.0</feature>
<feature>beanValidation-1.1</feature>
<feature>adminCenter-1.0</feature>
</featureManager>
<quickStartSecurity userName="wasadmin" userPassword="ded"/>
<keyStore id="defaultKeyStore" password="ded"/>
<!-- To access this server from a remote client add a host attribute to the following element, e.g. host="*" -->
<httpEndpoint id="defaultHttpEndpoint"
host="*"
httpPort="${http_port}"
httpsPort="${https_port}"/>
<!-- Log File Rotation and Maximun Number of Historical -->
<logging
logDirectory="sa-57487_api01_mob-biz-1/logs"
messageFileName="messages.log"
traceFileName="trace.log"
traceSpecification="*=info"
maxFileSize="10"
maxFiles="10"
copySystemStreams="false"
consoleLogLevel="INFO"
/>
<!-- Installation application -->
<application id="api" location="installedApps/sample-service-exposition-0.0.10.war" name="api-0.0.1-SNAPSHOT" type="war" context-root="api"/>
跟踪给了我这个:
[24/01/19 16:12:30:285 CET] 00000c50 com.ibm.ws.http.internal.VirtualHostImpl A CWWKT0016I: Web application available (default_host): http://xxx.fr.net.intra:9081/api/
[24/01/19 16:12:30:286 CET] 00000c52 com.ibm.ws.session.WASSessionCore I SESN0176I: A new session context will be created for application key default_host/api
[24/01/19 16:12:30:286 CET] 00000c52 com.ibm.ws.util I SESN0172I: The session manager is using the Java default SecureRandom implementation for session ID generation.
[24/01/19 16:12:30:307 CET] 00000c50 com.ibm.ws.app.manager.AppMessageHelper A CWWKZ0001I: Application AP12213-melchior-0.0.1-SNAPSHOT started in 2.298 seconds.
[24/01/19 16:12:30:497 CET] 00000c2d com.ibm.ws.webcontainer.osgi.mbeans.PluginGenerator I SRVE9103I: A configuration file for a web server plugin was automatically generated for this server at /applis/logs/57487-api01/wlc/sa-57487_api01_mob-biz-1/sa-57487_api01_mob-biz-1/logs/state/plugin-cfg.xml.
[24/01/19 16:12:30:532 CET] 00000c52 com.ibm.ws.webcontainer.webapp I SRVE0292I: Servlet Message - [sample-service-exposition-0.0.10]:.2 Spring WebApplicationInitializers detected on classpath
当我进入服务器 url 时:http://xxx.fr.net.intra:9081/api/
给我 :Context Root Not Found
任何帮助都比
解决方案
推荐阅读
- reactjs - Next.js & Passport.js/Express:如何调试“TypeError:无法读取未定义的属性‘0’”响应
- javascript - 获取选择框的选中值
- javascript - Javascript中的无限滚动与来自文件的数据
- python - 如何将任务分配给 dask 纱线集群中的特定工作人员
- arrays - 是否有将分段或()应用于多个逻辑数组的本机函数?
- javascript - 使用 FetchAPI 向数组添加数据
- javascript - JS函数自发执行
- python - CPPYY/CTYPES 将字符串数组作为 char* args[] 传递
- java - 无法将 txt 文件作为 JTextArea 读取
- python - 如何在python中将年划分为半年?