我是Spring的新手,我正在尝试使用spring-boot-starter-web来设置一个应用程序。该应用程序可以成功启动,但我发现当我将其部署到Payara服务器时,该应用程序会启动几次。
以下是Payara服务器打印的消息部分。
Initializing Soteria 1.1-b01.payara-p5 for context '/springweb'
Registering WebSocket filter for url pattern /*]]
ServletContext.log():2 Spring WebApplicationInitializers detected on classpath
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.7.4)
INFO 2470 --- [in-listener(56)] springweb.Application : Starting Application using Java 11.0.11 on 192.168.0.1 with PID 2470 (/usr/share/payara/payara5/glassfish/domains/domain1/applications/springweb/WEB-INF/classes/springweb/Application.class started by root in /usr/share/payara/payara5/glassfish/domains/domain1/config)
INFO 2470 --- [in-listener(56)] springweb.Application : No active profile set, falling back to 1 default profile: "default"
WebModule[/springerb] ServletContext.log():Initializing Spring embedded WebApplicationContext
INFO 2470 --- [in-listener(56)] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1975 ms
INFO 2470 --- [in-listener(56)] o.s.b.a.w.s.WelcomePageHandlerMapping : Adding welcome page: ServletContext resource [/index.html]
WARN 2470 --- [in-listener(56)] ion$DefaultTemplateResolverConfiguration : Cannot find template location: classpath:/templates/ (please add some templates, check your Thymeleaf configuration, or set spring.thymeleaf.check-template-location=false)
WARN 2470 --- [in-listener(56)] .s.s.UserDetailsServiceAutoConfiguration :
Using generated security password: b200e25a-ee5a-49f1-b7f4-047aa11fa4fb
This generated password is for development use only. Your security configuration must be updated before running your application in production.
INFO 2470 --- [in-listener(56)] o.s.s.web.DefaultSecurityFilterChain : Will secure any request with [org.springframework.security.web.session.DisableEncodeUrlFilter@78d61d6d, org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@2de8cf84, org.springframework.security.web.context.SecurityContextPersistenceFilter@6e79b72e, org.springframework.security.web.header.HeaderWriterFilter@1aca9626, org.springframework.security.web.csrf.CsrfFilter@387eb143, org.springframework.security.web.authentication.logout.LogoutFilter@39199309, org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter@29d0bc34, org.springframework.security.web.authentication.ui.DefaultLoginPageGeneratingFilter@34c4cf9e, org.springframework.security.web.authentication.ui.DefaultLogoutPageGeneratingFilter@5603f50, org.springframework.security.web.authentication.www.BasicAuthenticationFilter@1d190e55, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@30f8298b, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@7b7f364, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@5e208791, org.springframework.security.web.session.SessionManagementFilter@1ab27ca7, org.springframework.security.web.access.ExceptionTranslationFilter@330305b, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@196974a2
INFO 2470 --- [in-listener(56)] springweb.Application : Started Application in 5.942 seconds (JVM running for 274786.407)
Initializing Mojarra |version.string| for context '/springweb'
Initializing Soteria 1.1-b01.payara-p5 for context '/springweb'
Registering WebSocket filter for url pattern /*
ServletContext.log():2 Spring WebApplicationInitializers detected on classpath
. ____ _ __ _ _]]
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \]]
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \]]
\\/ ___)| |_)| | | | | || (_| | ) ) ) )]]
' |____| .__|_| |_|_| |_\__, | / / / /]]
=========|_|==============|___/=/_/_/_/]]
:: Spring Boot :: (v2.7.4)]]
.
.
.
.
我使用的依赖关系:
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<artifactId>tomcat-embed-logging-juli</artifactId>
<groupId>org.apache.tomcat.embed</groupId>
</exclusion>
<exclusion>
<artifactId>tomcat-embed-websocket</artifactId>
<groupId>org.apache.tomcat.embed</groupId>
</exclusion>
<exclusion>
<artifactId>tomcat-embed-el</artifactId>
<groupId>org.apache.tomcat.embed</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-loader</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-websocket</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-messaging</artifactId>
</dependency> <dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-oauth2-resource-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-oauth2-jose</artifactId>
</dependency>
<dependency>
<groupId>com.unboundid</groupId>
<artifactId>unboundid-ldapsdk</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.3</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
</dependencies>
我使用注解@SpringBootApplication来启动
@SpringBootApplication
public class Application extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
我已经删除或更改了依赖项的版本,但它无法解决问题。我不知道为什么它会重新启动应用程序和某些功能(如调度程序),因为它将被多次启动。
Payara服务器的版本为5.2021.1,Java版本为11
1条答案
按热度按时间qv7cva1a1#
您需要在pom.xml中排除tomcat嵌入式服务器,如下所示: