由于maven插件错误,spring boot maven项目未编译

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了由于maven插件错误,spring boot maven项目未编译相关的知识,希望对你有一定的参考价值。

我试图在netbeans中运行一个简单的spring启动项目,但代码没有编译。这是我得到的错误:

无法执行目标org.apache.maven.plugins:maven-surefire-plugin:2.17:test

我是编程的新手,我尝试了我在互联网上找到的所有东西,但仍然没有解决这个问题。我究竟做错了什么?

这是我的pom.xml:

HTTP://maven.Apache.org/下水道/maven-4.0.0.下水道"> 4.0.0

<groupId>com.example</groupId>
<artifactId>connectingDB</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>connectingDB</name>
<description>Demo project for Spring Boot</description>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.7.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-data-jpa</artifactId>
    </dependency>
    <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>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
                    <plugin>
                      <groupId>org.apache.maven.plugins</groupId>
                     <artifactId>maven-surefire-plugin</artifactId>
                  <version>2.17</version>
             </plugin>
    </plugins>
</build>

   //my main class
package com.example.connectingDB;

import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
  import 
  org.springframework.data.jpa.repository.config.EnableJpaRepositories;

  @EnableJpaRepositories(basePackages = 
   "com.example.connectingDB.repository")

  @SpringBootApplication
  public class ConnectingDbApplication {

   public static void main(String[] args) {
    SpringApplication.run(ConnectingDbApplication.class, args);
   }
   }

 // my model class
   package com.example.connectingDB.model;

  import javax.persistence.Column;
  import javax.persistence.Entity;
   import javax.persistence.GeneratedValue;
  import javax.persistence.Id;

 @Entity
 public class Users {
@Id
@GeneratedValue
@Column(name = "User Name")
private String userName;
@Column(name = "Password")
private String password;
@Column(name = "Role Id")
private String role;
@Column(name = "Name")
private String name;

public Users(){}

public String getUserName() {
    return userName;
}

public void setUserName(String userName) {
    this.userName = userName;
}

public String getPassword() {
    return password;
}

public void setPassword(String password) {
    this.password = password;
}

public String getRole() {
    return role;
}

public void setRole(String role) {
    this.role = role;
}

public String getName() {
    return name;
}

public void setName(String name) {
    this.name = name;
}



 }
// my repository

*/
package com.example.connectingDB.repository;
import com.example.connectingDB.model.Users;
 import org.springframework.data.jpa.repository.JpaRepository;


  public interface UsersRepository extends JpaRepository<Users, String>{





 }

// my resource

public class UsersResource {

@Autowired
UsersRepository usersRepository;

@GetMapping(value = "/all")
public List<Users> getAll() {
    return usersRepository.findAll();
}

@PostMapping(value = "/load")
public List<Users> persist(@RequestBody final Users users) {
    usersRepository.save(users);
    return usersRepository.findAll();
}

}




////// my yml file

spring:
datasource:
driverClassName: com.mysql.jdbc.Driver
url: jdbc:mysql://localhost:3306/userManagement
username:
password:
jpa:
hibernate.ddl-auto: update
generate-ddl: true
show-sql: true
答案

请检查这个答案,它可能会对你有所帮助。默认目标和源是1.5,但应该覆盖它:

ERROR Source option 1.5 is no longer supported. Use 1.6 or later

以上是关于由于maven插件错误,spring boot maven项目未编译的主要内容,如果未能解决你的问题,请参考以下文章

Maven-在当前项目和插件组中找不到前缀“spring-boot”的插件

SpringBootPlugin ‘org.springframework.boot:spring-boot-maven-plugin:‘ not found

SpringBootPlugin ‘org.springframework.boot:spring-boot-maven-plugin:‘ not found

Spring Boot Maven 插件 - spring-boot:run 和优雅关闭

Maven插件系列之spring-boot-maven-plugin

使用 Spring Boot BOM 管理 Maven 插件版本