错误:在 Spring Boot 1.5.9 版本中无法找到或加载主类...但在 1.4.7 中没有 [英] Error: Could not find or load main class ... in Spring Boot 1.5.9 version but not in 1.4.7
问题描述
我试图从
<modelVersion>4.0.0</modelVersion><groupId>com.example</groupId><artifactId>demo120417</artifactId><version>0.0.1-SNAPSHOT</version><包装>罐</包装><name>demo120417</name><description>Spring Boot 的演示项目</description><父母><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>1.5.9.RELEASE</version><relativePath/><!-- 从存储库中查找父级 --></父母><属性><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding><project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding><java.version>1.8</java.version></属性><依赖项><依赖><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-actuator</artifactId></依赖><依赖><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-security</artifactId></依赖><依赖><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-thymeleaf</artifactId></依赖><依赖><groupId>org.springframework.boot</groupId><artifactId>spring-boot-devtools</artifactId><scope>运行时</scope></依赖><依赖><groupId>com.h2database</groupId><artifactId>h2</artifactId><scope>运行时</scope></依赖><依赖><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><范围>测试</范围></依赖><依赖><groupId>org.springframework.security</groupId><artifactId>spring-security-test</artifactId><范围>测试</范围></依赖></依赖项><构建><插件><插件><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId></插件></plugins></build></项目>
这可能是什么根本原因?我花了将近 1 天的时间试图弄清楚我的构建路径是否有问题.通常项目上的红色感叹号将我指向图书馆问题.
我相信您是第一次这样做.您需要填写字段而不是将它们保留为默认值例如:
群组
com.myapp
工件
myapp
您需要在生成项目之前填写这些字段
I was trying to generate a starting spring boot project from https://start.spring.io/
When I use Spring Boot 1.5.9 version to generate the project I am getting the following
Error: Could not find or load main class com.example.demo120417.Demo120417Application
However; changing the version to Spring Boot 1.4.7 loads and runs the main class with no error.
I have actuator, security, thymeleaf, devtools, h2 in the dependency.
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>demo120417</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>demo120417</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.9.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</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-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
What could be the root cause for this? I spent almost 1 day trying to figure out if I had issue with build path. Usually having red exclamation mark on the project points me to the library issue.
I believe you are doing it for the first time . you need to fill up the fields than leaving them to default eg:
Group
com.myapp
Artifact
myapp
you need to fill there fields before genearting the project
这篇关于错误:在 Spring Boot 1.5.9 版本中无法找到或加载主类...但在 1.4.7 中没有的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!