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

----與君共勉

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM