0

I am trying to run a simple spring boot project in netbeans but the code is not compiling. This is the error I get:

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.17:test

I am new to programming and I tried everything I can find on internet and still haven't solved this problem. What am I doing wrong?

This is my 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
Maciej Jureczko
  • 1,560
  • 6
  • 19
  • 23
  • 1
    This: "Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.17:test" would suggest that there was a test failure rather than that the project "failed to compile". Could you (a) update your question with more details of the failure and (b) run your Maven build with `-DskipTests=true` to (temporarily) ignore any test failure (thereby allowing you to distinguish between a test failure and a failure to compile) – glytching Oct 08 '17 at 20:46
  • hi, I have updated with all the files in my project. Basically Im trying to create a rest application that will connect to mysql database and retrieve all user information. I tried to follow a tutorial and made this project. And now I dont know how to run this and see the results in my localhost. – Steffi_fdo Oct 08 '17 at 21:37

1 Answers1

0

Please check this answer, it may be of some help to you. The default target and source is 1.5 but it should be overwritten:

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

i-tms
  • 559
  • 5
  • 7