简体   繁体   English

为什么我在运行一个简单的 spring 启动 gradle 项目时得到 404 状态?

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

I am new to spring-boot.我是 spring-boot 的新手。 I have created a simple spring-boot version 2.2.6 project with gradle build.我用 gradle 构建了一个简单的 spring-boot 版本 2.2.6 项目。 I have created a welcome jsp just to print a header.我创建了一个欢迎 jsp 只是为了打印 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: 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.查看应用程序属性文件后,发现URL中传递了错误的端口。
No other technical error found.未发现其他技术错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么我在运行简单的 Spring Boot 应用程序时总是得到状态为“404”的 Whitelabel 错误页面 - Why do I always get Whitelabel Error Page with status "404" while running a simple Spring Boot Application 为什么我在运行 Spring 启动项目时总是得到状态为“404”的 Whitelabel 错误页面 - Why do I always get Whitelabel Error Page with status “404” while running Spring Boot Project 为什么我的Spring MVC项目出现404错误? - Why am I getting a 404 error with my Spring MVC project? 在 IntelliJ 中运行 Spring 启动 Gradle 应用程序时总是得到 404 - Always getting 404 when running Spring Boot Gradle app in IntelliJ 为什么我的 Spring Boot Web 应用程序会出现 404 错误? - Why am I getting a 404 error in my Spring Boot Web app? 我在使用 JpaRepository 创建一个简单的 Spring Boot 项目时得到 NoSuchBeanDefinitionexception - I am getting NoSuchBeanDefinitionexception while creating a simple Spring Boot project with JpaRepository spring和angulaJS(我收到类似HTTP Status 404的错误) - spring and angulaJS(i am getting error like HTTP Status 404 ) 我在Spring Boot中遇到API调用404错误 - I am getting a 404 Error on API Call in Spring Boot 简单的 Spring 引导项目给出 404 错误 - Simple Spring Boot Project is giving 404 Error 运行现有 spring 启动 gradle 项目的问题 - Issue running existing spring boot gradle project
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM