I am pretty new in Spring Boot and I am experiencing some problem trying to update the spring-boot-starter-parent parent project.
So, at the beginning I have this pom.xml file (it works fine, I can build the project and I have no problem):
<?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>com.springboot</groupId>
<artifactId>excel-api</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Excel API with Spring Boot</name>
<description>Spring Boot - working with Excel API</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.9.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-data</artifactId>
</dependency>
<!-- Start of excel dependencies -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.11</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.11</version>
</dependency>
<!-- End of excel dependencies -->
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
As you can see this pom.xml file contains this section:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.9.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
Please correct me if I am doing wrong assertion: from what I understoot it means that my pom.xml file is child of another pom.xml file of the spring-boot-starter-parent project having version 1.5.9.RELEASE. Is it this reasoning correct? In case where is defined this pom.xml file?
So at the moment I am succesfully using the 1.5.9.RELEASE version of this parent project. It is pretty old, I want to update it to the last one that is the 2.2.5.RELEASE, as shown here:
https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-parent
So I changed only the section of the previous pom.xml file in this way:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.5.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
The problem is that trying to build the project by this Maven command:
mvn clean install -DskipTests=true
I am obtaining the following error message:
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /home/developer/git/SOC-dashboard/src/main/java/com/springboot/excelapi/Application.java:[6,44] package org.springframework.boot.web.support does not exist
[ERROR] /home/developer/git/SOC-dashboard/src/main/java/com/springboot/excelapi/Application.java:[9,34] cannot find symbol
symbol: class SpringBootServletInitializer
[ERROR] /home/developer/git/SOC-dashboard/src/main/java/com/springboot/excelapi/Application.java:[15,9] method does not override or implement a method from a supertype
[INFO] 3 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.349 s
[INFO] Finished at: 2020-03-20T05:48:14-07:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project excel-api: Compilation failure: Compilation failure:
[ERROR] /home/developer/git/SOC-dashboard/src/main/java/com/springboot/excelapi/Application.java:[6,44] package org.springframework.boot.web.support does not exist
[ERROR] /home/developer/git/SOC-dashboard/src/main/java/com/springboot/excelapi/Application.java:[9,34] cannot find symbol
[ERROR] symbol: class SpringBootServletInitializer
[ERROR] /home/developer/git/SOC-dashboard/src/main/java/com/springboot/excelapi/Application.java:[15,9] method does not override or implement a method from a supertype
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
This is a major spring version upgrade from 1.x to 2.x. During such major version upgrade there are usually breaking changes such as package restructuring, removal of deprecated classes/methods, etc. It is best to refer to some sort of migration guide for such upgrade. You can refer to the official migration guide or some of other blog such as this.
Spring provides a dependency module which can be added to your pom file. This module analyses the application and provides diagnostic output for the changes required.
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-properties-migrator</artifactId>
<scope>runtime</scope>
</dependency>
For the specific issue raised in the question;
[ERROR] /home/developer/git/SOC-dashboard/src/main/java/com/springboot/excelapi/Application.java:[9,34] cannot find symbol
[ERROR] symbol: class SpringBootServletInitializer
The SpringBootServletInitializer
is now available from org.springframework.boot.web.servlet.support
package.