@EnableWebMvc
@ComponentScan
@EnableAutoConfiguration
public class LAuthServerApplication extends WebMvcConfigurerAdapter {
@Autowired
Environment env;
public static void main(String[] args) {
System.out.println("#################### Startup parameters ##############");
for (String s : args) {
System.out.println("Parameter: " + s);
}
System.out.println("######################################################");
SpringApplication.run(LAuthServerApplication.class, args);
}
@Override
public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
configurer.enable();
}
@Bean
public InternalResourceViewResolver viewResolver() {
InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
viewResolver.setPrefix("/WEB-INF/pages/");
viewResolver.setSuffix(".jsp");
return viewResolver;
}
为了使其可部署,我将这个类添加到我的项目中:
@Configuration
public class AppServletInitializer extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(Application.class);
}
}
POM:
<?xml version="1.0" encoding="UTF-8"?>
<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>
<groupId>ch.comlab.comweb</groupId>
<artifactId>LAuth</artifactId>
<version>1.0.0</version>
<packaging>war</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.5.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
</dependency>
<dependency>
<groupId>ch.comlab.comweb</groupId>
<artifactId>Infrastructure</artifactId>
<version>1.2.6</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<webResources>
<resource>
<directory>src/main/webapp</directory>
<filtering>true</filtering>
</resource>
</webResources>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<resources>
<resource>
<filtering>true</filtering>
<directory>src/main/resources/</directory>
</resource>
</resources>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spring-releases</id>
<url>https://repo.spring.io/libs-release</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-releases</id>
<url>https://repo.spring.io/libs-release</url>
</pluginRepository>
</pluginRepositories>
<name>LAuth</name>
</project>
我相信这要归功于Spring-Boot-Tomcat的嵌入式服务器。
您可以排除嵌入的tomcat并尝试吗?例如:
<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>
还要删除您在spring-boot-starter-web旁边给出的tomcat依赖项。
本文向大家介绍SpringBoot应用部署到Tomcat中无法启动的解决方法,包括了SpringBoot应用部署到Tomcat中无法启动的解决方法的使用技巧和注意事项,需要的朋友参考一下 背景 最近公司在做一些内部的小型Web应用时, 为了提高开发效率决定使用SpringBoot, 这货自带Servlet容器, 你在开发Web应用时可以直接在本地像运行控制台应用一样启动,省去了重复部署的时间;配置
当我试图在heroku上部署springboot应用程序时,出现了以下错误: 无法执行目标org.apache.Maven.plugins:maven-compiler-plugin:3.8.1:在项目后端编译(default-compile):错误编译:无效的目标版本:11->[Help 1]Remote:[error]Remote:[error]要查看错误的全部堆栈跟踪,请使用-e开关重新运行
我正在使用Java和Tomcat开发一个API项目。星期五一切都很好,但今天我不能在服务器上部署战争。下面是Tomcat中的堆栈错误: 以下是日志中的错误:
我在springboot应用程序中有筛选器。在embedded tomcate 9.0.34中运行该应用程序时,它可以正常工作。然而,当我创建war并将其部署在外部Tomcate8.5上时,它会抛出以下错误。
我有一个Spring启动Rest服务项目,它在我的本地机器上工作。当我运行应用程序为"Spring Boot App" 我可以通过转到访问rest服务 http://127.0.0.1:8080/persons/all 它返回JSON,因为它应该。 我换了pom。xml打包到war,然后我创建了一个war,作为- war文件名为“myapp-0.0.1-SNAPSHOT.war”,上传后,我试图通