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

时间:2017-10-08 20:41:56

标签: spring-boot netbeans

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

  

无法执行目标   org.apache.maven.plugins:行家-万无一失-插件:2.17:测试

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

这是我的 pom.xml

http://maven.apache.org/xsd/maven-4.0.0.xsd">     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 个答案:

答案 0 :(得分:0)

请检查此答案,可能会对您有所帮助。默认的目标和来源为1.5,但应将其覆盖:

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