gpt4 book ai didi

java - Spring Boot应用程序无法在Eclipse Oxygen中启动

转载 作者:行者123 更新时间:2023-11-30 02:21:24 24 4
gpt4 key购买 nike

我尝试制作一个 Spring-boot 应用程序,公开简单的 REST Web 服务。我遵循入门说明。我使用 Eclipse Oxygen IDE 进行开发。

当我尝试像 Java 应用程序一样启动应用程序时,出现错误:应用程序无法使用类路径启动。

这是我的参数:

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>fr.omb</groupId>
<artifactId>omb</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>war</packaging>


<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.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-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.1-901.jdbc4</version>
</dependency>

<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>${commons-lang.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
<version>4.1</version>
</dependency>

</dependencies>

<properties>
<java.version>1.8</java.version>
<commons-lang.version>2.6</commons-lang.version>
</properties>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<source>${java-version}</source>
<target>${java-version}</target>
</configuration>
</plugin>
</plugins>
</build>

</project>

主启动器类

/**
*
*/
package fr.omb;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

/**
* @author omb
*
*/
@Configuration
@EnableAutoConfiguration
@ComponentScan("fr.omb")
public class MainLauncher {
public static void main(String[] args) throws Exception {
SpringApplication.run(MainLauncher.class, args);
}

}

数据库配置

---

spring: profile: dev
jpa:

hibernate:
ddl-auto: create-drop
datasource:
platform: postgresql
url: jdbc:postgresql://localhost:5432/omb
username: xxxxxx
password: xxxxxx
driverClassName: org.postgresql.Driver

---

谢谢

最佳答案

您是否安装了 Oxygen 的 Spring Eclipse 插件?您需要作为 Spring(或 Spring-Boot)应用程序启动,而不是 Java 应用程序。

Spring-Boot Debug launch Configuration

关于java - Spring Boot应用程序无法在Eclipse Oxygen中启动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46719164/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com