Spring boot build error

Asked 2 years ago, Updated 2 years ago, 100 views

Error message Testing started at 8:03 AM ...

Task :cleanTest UP-TO-DATE Task :compileJava UP-TO-DATE Task :processResources UP-TO-DATE Task :classes UP-TO-DATE Task :compileTestJava FAILED /home/nakazaki/IdeaProjects/study/src/test/java/com/example/study/repository/UserRepositoryTest.java:20: error: cannot find symbol user.setAccount("TestUser01"); ^ symbol: method setAccount(String) location: variable user of type User /home/nakazaki/IdeaProjects/study/src/test/java/com/example/study/repository/UserRepositoryTest.java:21: error: cannot find symbol user.setEmail("[email protected]"); ^ symbol: method setEmail(String) location: variable user of type User /home/nakazaki/IdeaProjects/study/src/test/java/com/example/study/repository/UserRepositoryTest.java:22: error: cannot find symbol user.setPhoneNumber("010-1111-1111"); ^ symbol: method setPhoneNumber(String) location: variable user of type User /home/nakazaki/IdeaProjects/study/src/test/java/com/example/study/repository/UserRepositoryTest.java:23: error: cannot find symbol user.setCreatedAt(LocalDateTime.now()); ^ symbol: method setCreatedAt(LocalDateTime) location: variable user of type User /home/nakazaki/IdeaProjects/study/src/test/java/com/example/study/repository/UserRepositoryTest.java:24: error: cannot find symbol user.setCreatedBy("admin"); ^ symbol: method setCreatedBy(String) location: variable user of type User 5 errors FAILURE: Build failed with an exception.

java code

package com.example.study.repository;

import com.example.study.StudyApplicationTests; import com.example.study.model.entity.User; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired;

import java.time.LocalDateTime;

public class UserRepositoryTest extends StudyApplicationTests {

//Dependency Injection(DI)
@Autowired
 private UserRepository userRepository;

@Test
public void create(){
    //String sql = insert into user (%s ,%s,%d) value(accout,email,age)
   User user=new User();
   user.setAccount("TestUser01");
   user.setEmail("[email protected]");
   user.setPhoneNumber("010-1111-1111");
   user.setCreatedAt(LocalDateTime.now());
   user.setCreatedBy("admin");



    User newUser = userRepository.save(user);
    System.out.println("newUser:"+newUser);


}

public void read(){

}

public void update(){

}

public void delete(){

}

}

What's the problem?

spring-boot

2022-09-22 14:13

1 Answers

Caused by: org.gradle.api.internal.tasks.compile.CompilationFailedException: Compilation failed; see the compiler error output for details. 

Read the message.

A simple compilation error.

The detailed cause is written below.

Make sure the code in the User class is correct.

/home/nakazaki/IdeaProjects/study/src/test/java/com/example/study/repository/UserRepositoryTest.java:20: error: cannot find symbol user.setAccount("TestUser01"); ^ symbol: method setAccount(String) location: variable user of type User

/home/nakazaki/IdeaProjects/study/src/test/java/com/example/study/repository/UserRepositoryTest.java:21: error: cannot find symbol user.setEmail("[email protected]"); ^ symbol: method setEmail(String) location: variable user of type User

/home/nakazaki/IdeaProjects/study/src/test/java/ /example/study/repository/UserRepositoryTest.java:22: error: cannot find symbol user.setPhoneNumber("010-1111-1111"); ^ symbol: method setPhoneNumber(String) location: variable user of type User

/home/nakazaki/IdeaProjects/study/src/test/java/com/example/study/repository/UserRepositoryTest.java:23: error: cannot find symbol user.setCreatedAt(LocalDateTime.now()); ^ symbol: method setCreatedAt(LocalDateTime) location: variable user of type User

/home/nakazaki/IdeaProjects/study/src/test/java/com/example/study/repository/UserRepositoryTest.java:24: error: cannot find symbol user.setCreatedBy("admin"); ^ symbol: method setCreatedBy(String) location: variable user of type User

5 errors FAILURE: Build failed with an exception.


2022-09-22 14:13

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.