第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

Spring Boot URL 請(qǐng)求映射返回 NullPointerException

Spring Boot URL 請(qǐng)求映射返回 NullPointerException

動(dòng)漫人物 2023-03-02 14:58:52
我正在嘗試部署一個(gè)非常簡(jiǎn)單的 Spring Boot 應(yīng)用程序,其中導(dǎo)航到 localhost:8080/greetings 會(huì)顯示“來(lái)自 Spring Boot 的問(wèn)候語(yǔ)!”。但是,該 URL 似乎不起作用。導(dǎo)航到鏈接提示我出現(xiàn)空指針異常。我對(duì)這個(gè)問(wèn)題做了一些初步研究,但以下修復(fù)沒(méi)有奏效:將類從默認(rèn)包中移出并移入定義的包中使用@ComponentScan將我的控制器類移動(dòng)到我的應(yīng)用程序類的子包控制器類:package controllers;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RestController;@RestControllerpublic class HelloController {    @RequestMapping("/greetings")    public String index() {        return "Greetings from Spring Boot!";    }}應(yīng)用類:package controllers;import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.SpringBootApplication;@SpringBootApplicationpublic class Application {    public static void main(String[] args) {        SpringApplication.run(Application.class, args);    }}pom.xml<?xml version="1.0" encoding="UTF-8"?><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 https://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><groupId>org.springframework</groupId><artifactId>gs-spring-boot</artifactId><version>0.1.0</version><parent>    <groupId>org.springframework.boot</groupId>    <artifactId>spring-boot-starter-parent</artifactId>    <version>2.1.4.RELEASE</version></parent>   <properties>    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>    <java.version>1.8</java.version></properties><dependencies>    <dependency>        <groupId>org.springframework.boot</groupId>        <artifactId>spring-boot-starter-web</artifactId>    </dependency>    <dependency>        <groupId>org.springframework.boot</groupId>        <artifactId>spring-boot-starter-test</artifactId>        <scope>test</scope>    </dependency></dependencies></project>
查看完整描述

2 回答

?
DIEA

TA貢獻(xiàn)1820條經(jīng)驗(yàn) 獲得超2個(gè)贊

我找到了答案。原來(lái)我需要<groupId>在我的 pom.xml 中制作唯一的



查看完整回答
反對(duì) 回復(fù) 2023-03-02
?
慕森王

TA貢獻(xiàn)1777條經(jīng)驗(yàn) 獲得超3個(gè)贊

無(wú)論如何,在 servlet 容器或應(yīng)用程序服務(wù)器中運(yùn)行 spring-boot 應(yīng)用程序有什么意義?

您最初發(fā)布的應(yīng)用程序在mvn spring-boot:run使用java -jar ./target/gs-spring-boot-0.1.0.jar.

使用 spring-boot 的全部意義在于擁有一個(gè)嵌入式容器以便獨(dú)立運(yùn)行應(yīng)用程序。如果不是這樣,我建議減少依賴性,因?yàn)楫?dāng)部署到 servlet 容器(例如 Tomcat)或應(yīng)用程序服務(wù)器(例如 JBoss)時(shí),您的應(yīng)用程序可以變得更??;即在 KB 范圍內(nèi)而不是 16MB 范圍內(nèi)。


查看完整回答
反對(duì) 回復(fù) 2023-03-02
  • 2 回答
  • 0 關(guān)注
  • 157 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)