Hello,
I have recently switched to JDK 14 ....i generated Spring boot project with Java 14 and found that on adding below dependency ...intellji gives me dependency not found error. Can you please help me fix this issue
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>
Instructor
Yogesh Chawla Replied on 20/08/2020
Try this:
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>
And do install apache tomcat from this url:
https://tomcat.apache.org/download-70.cgi
If you already have then It should work.
It still does not work.
Can you give a try on your system and see if you are able to regenerate this issue ,if possible.
I am guessing if this problem is because of new Java 14...
let me know your thoughts or any alternative solution ?
Attaching my POM.xml for your reference .
Instructor
Yogesh Chawla Replied on 21/08/2020
Sailee, I also downloaded Java 14 first and then added the jar files which you sent me without versions and I was also getting the error.
But when I used version tag with required jar files in my pom.xml like I sent you above. It worked fine for me. May be there is some issue with Maven settings in your environment.
Did this to verify:
On the menu, clicks File -> Project Structure -> Platform Settings -> SDKs, added and point to the JDK 14 installed folder.
Project Settings -> Project, change both Project SDK and Project language level to JDK 13(Because JDK 14 option is not there)
Project Settings -> Modules, change the language level to JDK 13(Because JDK 14 option is not there)
Then
Go to File -> Settings -> Build, Execution and Deployment -> Build Tools -> Maven -> Runner -> Environment
Checked all Maven and JDK settings
I did clean and install steps also, it worked fine. I checked External Libraries in my Project and all the POM mentioned jars are there.
Check your Maven settings once as well:
File -> Settings -> Build, Execution and Deployment -> Build Tools -> Maven
This is my POM. I checked with your POM also and the same worked for.
If still it doesn't work for you then we will have to check all Maven settings in your local. Tell me, We will do that too.
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.3.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>demo</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>14</java.version>
</properties>
<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>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>13</source>
<target>13</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
Thanks Yogesh for detailed explanation.
It finally worked after i removed version tag for JSTL dependency and replaced it with scope tag with value as provided followed by MVN clean