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

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

Springboot:無法點擊網址

Springboot:無法點擊網址

慕勒3428872 2021-10-17 15:59:01
運行 Main 類后,我無法獲得輸出。Spring Boot 新手控制器@Controller public class WelcomeController {    private static final String welcomemsg = "Welcome Mr. %s!";    @GetMapping("/welcome/user")    @ResponseBody    public Welcome welcomeUser(@RequestParam(name = "name", required = false, defaultValue = "Java Fan") String name)    {        return new Welcome(String.format(welcomemsg, name));    } }主班package com.beans.mainsrc;import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.SpringBootApplication;@SpringBootApplication(scanBasePackages = { "com.beans" })public class DemoApplication {    public static void main(String[] args)    {        SpringApplication.run(DemoApplication.class, args);    }}有關運行主類的控制臺詳細信息2018-09-28 00:40:01.268  INFO 2304 --- [           main] com.beans.mainsrc.DemoApplication        : Starting DemoApplication on DESKTOP-551C51M with PID 2304 (F:\springbootdemo\demo\target\classes started by sparsh in F:\springbootdemo\demo) 2018-09-28 00:40:01.273  INFO 2304 --- [           main] com.beans.mainsrc.DemoApplication        : No active profile set, falling back to default profiles: default
查看完整描述

1 回答

?
躍然一笑

TA貢獻1826條經驗 獲得超6個贊

看起來您的 servlet 容器沒有啟動。請嘗試添加此 maven 依賴項


    <dependency>

        <groupId>org.springframework.boot</groupId>

        <artifactId>spring-boot-starter-web</artifactId>

    </dependency>

您可以刪除這些依賴項:


 <dependency>

    <groupId>org.springframework</groupId>

    <artifactId>spring-web</artifactId>

 </dependency>

 <dependency>

    <groupId>org.springframework.boot</groupId>

    <artifactId>spring-boot-starter</artifactId>

 </dependency>

它們由建議的啟動器提供。


查看完整回答
反對 回復 2021-10-17
  • 1 回答
  • 0 關注
  • 213 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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