I have a Spring Boot webapp developed and tested with the Netbeans internal Tomcat server.
I have setup the Application as a SpringBootServletInitializer
public class ServletInitializer extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(Testspringboot2Application.class);
}
}
@SpringBootApplication
@RestController
public class Testspringboot2Application {
@GetMapping("/")
public String greeting() {
return "Hello from root path";
}
public static void main(String[] args) {
SpringApplication.run(Testspringboot2Application.class, args);
}
}
with this pom.xml
<?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>3.2.2</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>org.theiner</groupId>
<artifactId>testspringboot2</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>testspringboot2</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>21</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.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
I have built the war file (testspringboot2.war) with Netbeans and deployed it on the standalone Tomcat. It was successfully exploded.
But: I cannot reach it on http://tomcatserver:8088/testspringboot2
. Do I need to take care of anything else to make this work?
This is true for both Debian 12 and Windows 10 ... so I think this is related to the Spring Boot project rather than the environment
EDIT: Versions
JDK 21
Tomcat 9.0.85 (Debian or Windows)
Apache Netbeans 20
Spring Boot Starter Parent 3.2.2 (start.spring.io with WAR and Maven options selected)
Tomcat 9 is for Jakarta EE8 (javax) which is not compatible with SpringBoot3 release.
I'd suggest going to Tomcat 10 or higher.