简体   繁体   中英

Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:1.5.6.RELEASE

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

Edit I 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?

My 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.


Action:

Consider defining a bean named 'entityManagerFactory' in your configuration.

Just add following code to your pom.xml

100% working

<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>

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:

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.

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

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>

Autowire your UserService in the controller class and UserRepository in UserService calss.

In UserService class:

@service
public class UserService{

    @Autowired
    private UserRepository userRepository;

    ....
}

In the controller class:

@Controller
class UserController{

      @Autowired
      private UserRepository userRepository;

      .....
}

You might need a goal configurations for spring-boot-maven-plugin, like below

 <executions>
    <execution>
      <goals>
        <goal>repackage</goal>
      </goals>
    </execution>
</executions>

Also, what's the maven command you are using to build and run?

Please define entityMangerFactory bean and inject it wherever it is required, I think you might be using JPA/Hibernate. Try this out

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM