![](/img/trans.png)
[英]Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.1.0.RELEASE
[英]Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:1.5.6.RELEASE
我是 spring boot 的新手,尝试了一个星期来解决这个问题。 我下载了plugin
,但仍然出现相同的错误,如果需要,工具/选项我没有代理
编辑我刚刚创建了一个用户可以注册或登录的基本项目。我有控制器、服务存储库、域类。但是当我想检查我的数据库是否创建时,我得到了这个错误。我检查了我的plugins
,如果我错过了一些但一切似乎都是正确的。 你能给我一些可能是什么问题的猜测吗?
我的 pom.xml
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.6.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-web</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>javax.persistence</artifactId>
<version>2.1.0</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-commons</artifactId>
<version>1.13.6.RELEASE</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
<version>1.11.6.RELEASE</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>1.5.6.RELEASE</version>
<type>jar</type>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>1.5.6.RELEASE</version>
<configuration>
<fork>true</fork>
</configuration>
</plugin>
</plugins>
</build>
安慰
Description:
Field `userRepository` in `com.example.service.UserService` required a bean named 'entityManagerFactory' that could not be found.
Action:
Consider defining a bean named 'entityManagerFactory' in your configuration.
只需将以下代码添加到您的pom.xml
100% 工作
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
<executions>
<execution>
<phase>none</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
我面临同样的问题,但情况不同。 我有一个 Maven 多模块项目。 我的核心模块继承自另一个使用spring-boot-maven-plugin:2.1.2.RELEASE
插件的模块。 当我尝试编译核心模块时,出现了同样的错误:
Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.1.2.RELEASE:repackage (repackage) on project it-core
我认为出现问题是因为我的核心模块没有@SpringBootApplication
主类。
以下解决方案解决了我的问题。
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
<executions>
<execution>
<phase>none</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
也许你不需要jib-maven-plugin
尝试删除以下内容
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>1.5.6.RELEASE</version>
<type>jar</type>
</dependency>
和
<version>1.5.6.RELEASE</version>
<configuration>
<fork>true</fork>
</configuration>
在 UserService 类中自动装配控制器类中的 UserService 和 UserRepository。
在用户服务类中:
@service
public class UserService{
@Autowired
private UserRepository userRepository;
....
}
在控制器类中:
@Controller
class UserController{
@Autowired
private UserRepository userRepository;
.....
}
您可能需要 spring-boot-maven-plugin 的目标配置,如下所示
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
另外,您用来构建和运行的 maven 命令是什么?
请定义 entityMangerFactory bean 并将其注入到需要的地方,我认为您可能正在使用 JPA/Hibernate。 试试这个
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.