亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何解決Spring Boot應用中的“Whitelabel Error Page”相關問題

如何解決Spring Boot應用中的“Whitelabel Error Page”相關問題

達令說 2023-03-31 15:29:43
我正在嘗試執行我的新 Spring Boot 應用程序。前兩個類是:import org.springframework.boot.autoconfigure.SpringBootApplication;@SpringBootApplicationpublic class UbbioneApplication {    public static void main(String[] args) {        SpringApplication.run(UbbioneApplication.class, args);    }}然后是 servlet Initializer 類import org.springframework.boot.builder.SpringApplicationBuilder;import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;public class ServletInitializer extends SpringBootServletInitializer {    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {        return application.sources(UbbioneApplication.class);    }}但是當我習慣于通過mvn spring-boot:run在控制臺中編寫來運行我的應用程序時,我會出現以下消息:白標錯誤頁面你能幫我解決這個問題嗎?提前致謝。
查看完整描述

1 回答

?
慕村9548890

TA貢獻1884條經驗 獲得超4個贊

我想我有一個答案:


我為我的應用程序創建了一個控制器,并按如下方式更新了我的代碼:


import org.springframework.boot.autoconfigure.EnableAutoConfiguration;

import org.springframework.context.annotation.ComponentScan;

import org.springframework.context.annotation.Configuration;


@Configuration

@EnableAutoConfiguration

@ComponentScan(basePackages = {"Name_controller_path"})

public class Application {

    public static void main(String[] args) {

        SpringApplication.run(Application.class, args);

    }

}

然后我的控制器將如下所示:


import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestMethod;

import org.springframework.web.bind.annotation.RestController;


@RestController

public class Appcontroller {


    @RequestMapping(value = "/home", method = RequestMethod.GET)

    String home() {

        return "home";

    }

}

然后使用此路徑查看您的執行情況:http://localhost:8080/home。



查看完整回答
反對 回復 2023-03-31
  • 1 回答
  • 0 關注
  • 152 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號