There is a sample spring boot(version 3.0.3) web application like this:
The part of pom.xml
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.0.3</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>demo</name>
<description>Demo project for Spring Boot</description>
<properties>
<start-class>matin.example.demo.DemoApplication</start-class>
<java.version>17</java.version>
</properties>
<dependencies>
<!--<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</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>
</dependencies>
and
package matin.example.demo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
@SpringBootApplication
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}
and
package matin.example.demo.api;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class FController {
@GetMapping(value = "/re")
public String viewHomePage(/*Model model, HttpServletRequest request*/) {
/*request.getSession().setAttribute("onlineUser", request.getSession().getAttribute("onlineUser") == null ? 1 : Integer.valueOf(request.getSession().getAttribute("onlineUser").toString()) + 1);
System.out.println(request.getSession().getAttribute("onlineUser") + "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<");*/
return "index";
}
}
when i request as localhost:8080/re
, i got 404 not found error, but when i downgrade the version of spring boot to 2.7.7, it is worked successfully.
Where is it changed in the version of 3.x and what do i do?