简体   繁体   中英

Why am I getting 404 status on running a simple spring boot gradle project?

I am new to spring-boot. I have created a simple spring-boot version 2.2.6 project with gradle build. I have created a welcome jsp just to print a header. I get 404 status when i run it on my server with http://localhost:8081/welcome.html Following is my build.gradle, application class, controller class and application.properties file:

//build.gradle    
plugins {
    id 'org.springframework.boot' version '2.2.6.RELEASE'
    id 'io.spring.dependency-management' version '1.0.9.RELEASE'
    id 'java'
    }

    group = 'com.banuprojects'
    version = '0.0.1-SNAPSHOT'
    sourceCompatibility = '11'

    repositories {
        mavenCentral()
    }

    dependencies {
        implementation 'org.springframework.boot:spring-boot-starter-web'
        implementation 'org.apache.tomcat.embed:tomcat-embed-jasper'
        implementation 'javax.servlet:jstl'
        testImplementation('org.springframework.boot:spring-boot-starter-test') {
            exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
        }
    }

    test {
        useJUnitPlatform()
    }

//application class
        package com.banuprojects.lmsdemo;

    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;

    @SpringBootApplication
    public class LmsdemoApplication {

        public static void main(String[] args) {
            SpringApplication.run(LmsdemoApplication.class, args);
        }

    }

    //controller class
        package com.banuprojects.lmsdemo;

        import org.springframework.stereotype.Controller;
        import org.springframework.web.bind.annotation.RequestMapping;
        import org.springframework.web.servlet.ModelAndView;

        @Controller
        public class TestController {

            @RequestMapping("/welcome.html")
            public ModelAndView firstPage() {
                return new ModelAndView("welcome");
            }

        }

//application.properties
        spring.mvc.view.prefix:/WEB-INF/jsp/
        spring.mvc.view.suffix:.jsp

I am not sure where I have one wrong with the implementation. Any help will be appreciated. Thank you

As discussed over the comments. After seeing the application properties file, found that wrong port was passed in the URL.
No other technical error found.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM