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

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

Spring-boot 應用程序在啟動時不會自動部署

Spring-boot 應用程序在啟動時不會自動部署

慕娘9325324 2023-06-08 13:58:06
我按照在線教程在 Eclipse IDE 中創建了一個 spring boot 基本應用程序。當我嘗試將該應用程序作為 java 應用程序運行時,該應用程序未部署在嵌入式 tomcat 中。我在谷歌上搜索了很多并嘗試了一些找到的解決方案。但是,沒有一個對我有用。我在這里粘貼代碼。請讓我知道任何可能的問題。代碼:-pom.xml:-<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 http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><groupId>com.test</groupId><artifactId>spring-boot-example</artifactId><version>0.0.1-SNAPSHOT</version><name>Spring Boot Example</name><packaging>jar</packaging><parent>    <groupId>org.springframework.boot</groupId>    <artifactId>spring-boot-starter-parent</artifactId>    <version>2.1.7.RELEASE</version></parent><dependencies>    <dependency>        <groupId>org.springframework.boot</groupId>        <artifactId>spring-boot-starter-web</artifactId>    </dependency>    <dependency>        <groupId>org.springframework.boot</groupId>        <artifactId>spring-boot-autoconfigure</artifactId>    </dependency></dependencies>SpringBootExample.java:-package com.test;import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.SpringBootApplication;import com.test.config.AppConfiguration;@SpringBootApplicationpublic class SpringBootExample {    public static void main(String[] args) {        System.out.println("Started main");        SpringApplication.run(AppConfiguration.class, args);        System.out.println("Ending main");    }}AppConfiguration.java:-package com.test.config;import org.springframework.context.annotation.Bean;import org.springframework.context.annotation.Configuration;import com.test.beans.SampleBean;@Configurationpublic class AppConfiguration {    @Bean    public SampleBean getSampleBean() {        return new SampleBean();    }}SampleBean.java:-package com.test.beans;public class SampleBean {    public SampleBean() {        System.out.println("In constructor of SampleBean");    }}
查看完整描述

1 回答

?
繁星coding

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

@EnableAutoConfiguration我添加了注釋AppConfiguration.java,它開始工作了。應用程序無法確定要ServletWebServerFactory創建的類型。添加上面的注釋后,它為類路徑中已經存在的嵌入式 tomcat 創建了它。



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

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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