当时不懂servlet有啥用,各种百度了半天才解决。遇到相同问题的可以参考下
SpringBoot+外部Tomcat启动报错 .NoClassDefFoundError: javax/servlet/http/HttpSessionIdListener`_thewindkee的博客-CSDN博客
https://blog.csdn.net/thewindkee/article/details/118419817
打包成jar包,java -jar运行时也是各种问题,没有主属性啦,启动springboot报错啦,换了打包插件后执行 mvn package spring-boot:repackage 才解决。
maven
打成war包\jar包,去到项目根目录下,执行命令 mvn package spring-boot:repackage
pom.xml 相关设置(加粗是jar包、war包打包重点)
<?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>
<parent>
<groupId>com.mavenLearn</groupId>
<artifactId>parent</artifactId>
<version>1.0</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
<artifactId>httpClientService</artifactId>
** <packaging>war</packaging>**
<!-- <packaging>jar</packaging> -->
<name>httpClientService</name>
<dependencies>
<dependency>
** <groupId>javax.servlet</groupId>**
** <artifactId>javax.servlet-api</artifactId>**
** <version>4.0.1</version>**
</dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>5.3.9</version>
** <dependency>**
** <groupId>org.springframework.boot</groupId>**
** <artifactId>spring-boot-starter-web</artifactId>**
** <exclusions>**
** <exclusion>**
** <artifactId>spring-boot-starter-tomcat</artifactId>**
** </exclusion>**
** </exclusions>**
** <version>2.5.4</version>**
** </dependency>**
** <scope>compile</scope>**
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<version>2.5.4</version>
<scope>test</scope>
<artifactId>spring-boot</artifactId>
<artifactId>spring-boot-autoconfigure</artifactId>
<artifactId>spring-boot-starter</artifactId>
<artifactId>spring-boot-maven-plugin</artifactId>
<type>maven-plugin</type>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.3.1</version>
</dependencies>
<build>
<finalName>httpClientService</finalName>
<pluginManagement>
<plugins>
<plugin>
** <artifactId>spring-boot-maven-plugin</artifactId>**
<configuration>
** <mainClass>com.http.client.service.HttpClientServiceApplication</mainClass>**
** <layout>WAR</layout>**
** <!--<layout>JAR</layout>-->**
</configuration>
<executions>
<execution>
** <goals>**
** <goal>repackage</goal>**
** </goals>**
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
Sign in to make a reply
净净一隅
当时不懂servlet有啥用,各种百度了半天才解决。遇到相同问题的可以参考下
SpringBoot+外部Tomcat启动报错 .NoClassDefFoundError: javax/servlet/http/HttpSessionIdListener`_thewindkee的博客-CSDN博客
https://blog.csdn.net/thewindkee/article/details/118419817
打包成jar包,java -jar运行时也是各种问题,没有主属性啦,启动springboot报错啦,换了打包插件后执行 mvn package spring-boot:repackage 才解决。
maven
打成war包\jar包,去到项目根目录下,执行命令 mvn package spring-boot:repackage
pom.xml 相关设置(加粗是jar包、war包打包重点)
<?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>
<parent>
<groupId>com.mavenLearn</groupId>
<artifactId>parent</artifactId>
<version>1.0</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
<artifactId>httpClientService</artifactId>
<version>1.0</version>
** <packaging>war</packaging>**
<!-- <packaging>jar</packaging> -->
<name>httpClientService</name>
<dependencies>
<dependency>
** <groupId>javax.servlet</groupId>**
** <artifactId>javax.servlet-api</artifactId>**
** <version>4.0.1</version>**
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>5.3.9</version>
</dependency>
** <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>**
** <version>2.5.4</version>**
** </dependency>**
** <dependency>**
** <groupId>org.springframework.boot</groupId>**
** <artifactId>spring-boot-starter-tomcat</artifactId>**
** <version>2.5.4</version>**
** <scope>compile</scope>**
** </dependency>**
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<version>2.5.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot</artifactId>
<version>2.5.4</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure</artifactId>
<version>2.5.4</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<version>2.5.4</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.5.4</version>
<type>maven-plugin</type>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.3.1</version>
<type>maven-plugin</type>
</dependency>
</dependencies>
<build>
<finalName>httpClientService</finalName>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
** <artifactId>spring-boot-maven-plugin</artifactId>**
** <version>2.5.4</version>**
<configuration>
** <mainClass>com.http.client.service.HttpClientServiceApplication</mainClass>**
** <layout>WAR</layout>**
** <!--<layout>JAR</layout>-->**
</configuration>
<executions>
<execution>
** <goals>**
** <goal>repackage</goal>**
** </goals>**
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>