java 无法执行目标 org.springframework.boot:spring-boot-maven-plugin:1.5.6.RELEASE
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/45400701/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:1.5.6.RELEASE
提问by Vusala Hasanli
I am new to spring boot and try to solve this problem for a week.
I downloaded plugin
and still get the same error, and Tools/Options I have no proxy if needed
我是 spring boot 的新手,尝试解决这个问题一周。我下载plugin
并仍然遇到相同的错误,如果需要,我没有代理工具/选项
EditI just created a basic project that user can sign up or log in. And I have controller, service repository, domain classes .But when I want to check if my database created I get this error .I checked my plugins
if i misses some but everything seems rigth . Can you give me some guess about what can be problem?
编辑我刚刚创建了一个用户可以注册或登录的基本项目。我有控制器、服务存储库、域类。但是当我想检查我的数据库是否创建时,我收到了这个错误。我检查了我plugins
是否错过了一些但是一切似乎都正确。你能给我一些猜测可能是什么问题吗?
My pom.xml
我的 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>
Console
安慰
Description:
描述:
Field userRepository
in com.example.service.UserService
required a bean named 'entityManagerFactory' that could not be found.
场userRepository
中com.example.service.UserService
需要一个名为“entityManagerFactory的”不能被发现豆。
Action:
行动:
Consider defining a bean named 'entityManagerFactory' in your configuration.
考虑在您的配置中定义一个名为“entityManagerFactory”的 bean。
回答by Michael Pacheco
I'm facing the same problem, but in a different scenario.
I have a Maven multi module project.
My core module inherits from another one that makes use of spring-boot-maven-plugin:2.1.2.RELEASE
plugin.
When I tried to compile the core module the same error has occurred:
我面临同样的问题,但在不同的情况下。我有一个 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
I think the problem occurs because my core module does not have an @SpringBootApplication
main class.
我认为出现问题是因为我的核心模块没有@SpringBootApplication
主类。
The following solution solved my problem.
以下解决方案解决了我的问题。
<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>
Maybe you don't need the jib-maven-plugin
也许你不需要 jib-maven-plugin
回答by Omar
Autowire your UserService in the controller class and UserRepository in UserService calss.
在控制器类中自动装配您的 UserService,在 UserService 类中自动装配 UserRepository。
In UserService class:
在 UserService 类中:
@service
public class UserService{
@Autowired
private UserRepository userRepository;
....
}
In the controller class:
在控制器类中:
@Controller
class UserController{
@Autowired
private UserRepository userRepository;
.....
}
回答by Omar
Try removing the following
尝试删除以下内容
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>1.5.6.RELEASE</version>
<type>jar</type>
</dependency>
And
和
<version>1.5.6.RELEASE</version>
<configuration>
<fork>true</fork>
</configuration>
回答by Anil Kumar Athuluri
You might need a goal configurations for spring-boot-maven-plugin, like below
您可能需要 spring-boot-maven-plugin 的目标配置,如下所示
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
Also, what's the maven command you are using to build and run?
另外,您用来构建和运行的 Maven 命令是什么?
回答by Anil Kumar Athuluri
Please define entityMangerFactory bean and inject it wherever it is required, I think you might be using JPA/Hibernate. Try this out
请定义 entityMangerFactory bean 并在需要的地方注入它,我认为您可能正在使用 JPA/Hibernate。试试这个