【发布时间】:2020-07-28 13:09:28
【问题描述】:
我正在关注this tutorial 以了解如何在 Wildfly 上部署基本的 Spring Boot 应用程序。 该应用程序使用嵌入式 tomcat 服务器正确运行,但在 wildfly 上不起作用。我在我的 Eclipse 控制台上没有看到任何与 Spring Boot 相关的日志,好像 Spring Boot 框架甚至没有在 Wildfly 上加载。
这是主要的(也是唯一的)java类:
package com.example.helloworld;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@SpringBootApplication
public class HelloworldApplication extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(HelloworldApplication.class, args);
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(applicationClass);
}
private static Class<HelloworldApplication> applicationClass = HelloworldApplication.class;
}
@RestController
class HelloController {
@RequestMapping("/hello/{name}")
String hello(@PathVariable String name) {
return "Hi "+name+" !";
}
}
这是我的 pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.0.BUILD-SNAPSHOT</version>
<relativePath />
<!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>helloworld</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>helloworld</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>springbootwildfly</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</project>
这是eclipse控制台日志的相关部分:
15:54:57,852 INFO [org.jboss.as.server.deployment] (MSC service thread 1-1) WFLYSRV0027: Starting deployment of "helloworld-0.0.1-SNAPSHOT.war" (runtime-name: "helloworld-0.0.1-SNAPSHOT.war")
15:54:57,868 INFO [org.wildfly.extension.undertow] (MSC service thread 1-5) WFLYUT0006: Undertow HTTP listener default listening on 127.0.0.1:8080
15:54:57,875 INFO [org.jboss.as.ejb3] (MSC service thread 1-8) WFLYEJB0493: EJB subsystem suspension complete
15:54:57,956 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-4) WFLYJCA0001: Bound data source [java:/jdbc/kyc]
15:54:57,979 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-1) WFLYJCA0001: Bound data source [java:jboss/datasources/ExampleDS]
15:54:58,255 INFO [org.wildfly.extension.undertow] (MSC service thread 1-1) WFLYUT0006: Undertow HTTPS listener https listening on 127.0.0.1:8443
15:54:58,318 INFO [org.jboss.ws.common.management] (MSC service thread 1-1) JBWS022052: Starting JBossWS 5.3.0.Final (Apache CXF 3.3.3)
15:55:00,042 WARN [org.jboss.as.ee] (MSC service thread 1-1) WFLYEE0007: Not installing optional component org.springframework.http.server.reactive.ServletServerHttpResponse$ResponseAsyncListener due to an exception (enable DEBUG log level to see the cause)
15:55:00,043 WARN [org.jboss.as.ee] (MSC service thread 1-1) WFLYEE0007: Not installing optional component org.springframework.http.server.reactive.ServletHttpHandlerAdapter$HandlerResultAsyncListener due to an exception (enable DEBUG log level to see the cause)
15:55:00,045 WARN [org.jboss.as.ee] (MSC service thread 1-1) WFLYEE0007: Not installing optional component org.springframework.http.server.ServletServerHttpAsyncRequestControl due to an exception (enable DEBUG log level to see the cause)
15:55:00,047 WARN [org.jboss.as.ee] (MSC service thread 1-1) WFLYEE0007: Not installing optional component org.springframework.web.context.request.async.StandardServletAsyncWebRequest due to an exception (enable DEBUG log level to see the cause)
15:55:00,051 WARN [org.jboss.as.ee] (MSC service thread 1-1) WFLYEE0007: Not installing optional component org.springframework.http.server.reactive.ServletServerHttpRequest$RequestAsyncListener due to an exception (enable DEBUG log level to see the cause)
15:55:00,150 INFO [org.infinispan.factories.GlobalComponentRegistry] (MSC service thread 1-5) ISPN000128: Infinispan version: Infinispan 'Infinity Minus ONE +2' 9.4.16.Final
15:55:00,465 INFO [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 76) WFLYCLINF0002: Started client-mappings cache from ejb container
15:55:00,628 INFO [io.undertow.servlet] (ServerService Thread Pool -- 85) 1 Spring WebApplicationInitializers detected on classpath
15:55:00,665 INFO [javax.enterprise.resource.webcontainer.jsf.config] (ServerService Thread Pool -- 85) Initializing Mojarra 2.3.9.SP04 for context '/helloworld-0.0.1-SNAPSHOT'
15:55:01,579 INFO [org.wildfly.extension.undertow] (ServerService Thread Pool -- 85) WFLYUT0021: Registered web context: '/helloworld-0.0.1-SNAPSHOT' for server 'default-server'
15:55:01,677 INFO [org.jboss.as.server] (ServerService Thread Pool -- 44) WFLYSRV0010: Deployed "helloworld-0.0.1-SNAPSHOT.war" (runtime-name : "helloworld-0.0.1-SNAPSHOT.war")
15:55:01,744 INFO [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0212: Resuming server
15:55:01,746 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0060: Http management interface listening on http://127.0.0.1:9990/management
15:55:01,746 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0051: Admin console listening on http://127.0.0.1:9990
15:55:01,746 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0025: WildFly Full 18.0.1.Final (WildFly Core 10.0.3.Final) started in 7452ms - Started 540 of 766 services (375 services are lazy, passive or on-demand)
我正在使用 eclipse 20-03、wildfly 18.0.1 和 spring boot 2.2.6,我在这里缺少什么?
提前致谢。
更新:我的 pom.xml 引发了关于 javax.servlet 依赖项的警告,告诉我我正在覆盖 spring-boot-dependencies 中定义的托管版本。
【问题讨论】:
-
我承认我不是 Springboot 专家,但为什么要在服务器上运行具有嵌入式服务器或独立环境的环境 - Springboot?我认为 Springboot 旨在独立存在,而不是需要容器。
-
我也不是专家,但是我要写的软件需要部署在wildfly应用服务器上,所以我正在试验它:)
-
WARN [org.jboss.as.ee](MSC 服务线程 1-1)WFLYEE0007 看起来需要调查
-
看起来它{已部署,但它不会启动反应组件,您必须在 DEBUG 级别启用记录器以获取更多信息,但无论如何您可以调用您的服务,因为它已部署,所以你可以试试 {yourhostip}:{wildfly_port}/helloworld-0.0.1-SNAPSHOT/hello/test 例如
标签: java spring-boot wildfly