SpringBoot导入jsp依赖始终报错
Posted 蟹蟹
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了SpringBoot导入jsp依赖始终报错相关的知识,希望对你有一定的参考价值。
先粘出我自己的pom代码:
1 <?xml version="1.0" encoding="UTF-8"?> 2 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 3 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> 4 <modelVersion>4.0.0</modelVersion> 5 <parent> 6 <groupId>org.springframework.boot</groupId> 7 <artifactId>spring-boot-starter-parent</artifactId> 8 <version>1.5.6.RELEASE</version> 9 <relativePath/> <!-- lookup parent from repository --> 10 </parent> 11 <groupId>com.sblueice</groupId> 12 <artifactId>demo</artifactId> 13 <version>0.0.1-SNAPSHOT</version> 14 <packaging>war</packaging> 15 <name>demo</name> 16 <description>Demo project for Spring Boot</description> 17 18 <properties> 19 <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 20 <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> 21 <java.version>1.8</java.version> 22 </properties> 23 24 <dependencies> 25 <dependency> 26 <groupId>org.springframework.boot</groupId> 27 <artifactId>spring-boot-starter-web</artifactId> 28 </dependency> 29 <dependency> 30 <groupId>javax.servlet</groupId> 31 <artifactId>javax.servlet-api</artifactId> 32 <scope>provided</scope> 33 </dependency> 34 35 <!--支持jsp --> 36 <dependency> 37 <groupId>javax.servlet</groupId> 38 <artifactId>jstl</artifactId> 39 <version>1.2</version> 40 </dependency> 41 42 <dependency> 43 <groupId>com.mchange</groupId> 44 <artifactId>c3p0</artifactId> 45 <version>0.9.5.2</version> 46 </dependency> 47 <!-- 设置为provided是在打包时会将该包排除,因为要放到独立的tomcat中运行,是不需要的。 --> 48 <dependency> 49 <groupId>org.springframework.boot</groupId> 50 <artifactId>spring-boot-starter-tomcat</artifactId> 51 <scope>provided</scope> 52 </dependency> 53 <dependency> 54 <groupId>org.springframework.boot</groupId> 55 <artifactId>spring-boot-starter-test</artifactId> 56 <scope>test</scope> 57 </dependency> 58 <dependency> 59 <groupId>org.springframework.boot</groupId> 60 <artifactId>spring-boot-devtools</artifactId> 61 <optional>true</optional> 62 </dependency> 63 <dependency> 64 <groupId>org.springframework.boot</groupId> 65 <artifactId>spring-boot-starter-jdbc</artifactId> 66 </dependency> 67 <dependency> 68 <groupId>org.mybatis.spring.boot</groupId> 69 <artifactId>mybatis-spring-boot-starter</artifactId> 70 <version>1.3.2</version> 71 </dependency> 72 <dependency> 73 <groupId>mysql</groupId> 74 <artifactId>mysql-connector-java</artifactId> 75 <scope>runtime</scope> 76 </dependency> 77 78 </dependencies> 79 80 <build> 81 <plugins> 82 <plugin> 83 <groupId>org.springframework.boot</groupId> 84 <artifactId>spring-boot-maven-plugin</artifactId> 85 </plugin> 86 <plugin> 87 <groupId>org.apache.maven.plugins</groupId> 88 <artifactId>maven-compiler-plugin</artifactId> 89 <version>3.1</version> 90 <configuration> 91 <source>1.8</source> 92 <target>1.8</target> 93 </configuration> 94 </plugin> 95 </plugins> 96 </build> 97 98 </project>
修改一:先说父类依赖版本号,根据百度由2.0.1改为了1.5.6
修改二:再说导入jsp依赖的报错:Missing artifact org.apache.tomcat.embed:tomcat-embed-jasper:jar:8.5.16
如果不添加jsp依赖,就直接下载jsp文件,添加了就报错,现在我已经懵了。。。。
记录一下,有大神解答更是求之不得!!!
2019-10-10自己已经解决:
最后发现是版本的问题,从1.5.6测试到了2.0.3,发现2.0.3这个版本没有问题,证明了这个版本适合我的电脑和我的eclipse
操作系统:win10 64位
eclipse:Version: 2019-09 R (4.13.0)
maven应该是3.5.0
1、下面是jsp需要的依赖:
<!--servlet依赖begin --> <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <scope>provided</scope> </dependency> <!--servlet依赖end --> <!--jsp标签库begin --> <dependency> <groupId>javax.servlet</groupId> <artifactId>jstl</artifactId> <version>1.2</version> </dependency> <!--jsp标签库end --> <dependency> <groupId>org.apache.tomcat.embed</groupId> <artifactId>tomcat-embed-jasper</artifactId> <scope>provided</scope> </dependency>
2、接着是application.yml中添加前后缀
spring:
mvc:
view:
prefix: /WEB-INF/views
suffix: .jsp
----与君共勉
以上是关于SpringBoot导入jsp依赖始终报错的主要内容,如果未能解决你的问题,请参考以下文章