This a springboot Application. It run perfectly but did not get output (it shows me HTTP Status 404 error in browser)
pom.xml
<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.exaample.demo</groupId>
<artifactId>SpringBootMaven</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>Maven spring boot project</name>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.9.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
<properties>
<java.version>1.8</java.version>
</properties>
</project>
Springboot start Class Main Method
package com.example.demo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class WebMainMethod {
public static void main(String[] args) {
SpringApplication.run(WebMainMethod.class, args);
}
}
controller is loading after main class
**Rest Controller**
package com.example.demo.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class HelloController {
@RequestMapping("/hello")
public String sayHi() {
return "Hi";
}
}
Url : http://localhost:8080/hello output


You can try this. Using application.properties /yml
The most straightforward way of changing the context path is to set the property in the application.properties: server.servlet.context-path=/demoApp
Instead of putting the properties file in src/main/resources, we can also keep it in the current working directory (outside of the classpath). Java System Property.
http://localhost:8090/demoApp/hello for more info. https://www.baeldung.com/spring-boot-context-path
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With