spring boot gradle 기반 오류

조회수 1096회

build.gradle

plugins { id 'org.springframework.boot' version '2.1.6.RELEASE' id 'java' }

apply plugin: 'io.spring.dependency-management'

group = 'com.example' version = '0.0.1-SNAPSHOT' sourceCompatibility = '1.8'

repositories { mavenCentral() }

dependencies { compile('org.springframework.boot:spring-boot-starter-thymeleaf') compile('org.springframework.boot:spring-boot-starter-data-jpa') compile('mysql:mysql-connector-java') compile('org.projectlombok:lombok') implementation 'org.springframework.boot:spring-boot-starter-web' testImplementation 'org.springframework.boot:spring-boot-starter-test' }

User.java

package com.example.study.model.entity;

//import com.example.study.model.enumclass.UserStatus; import lombok.*; import lombok.experimental.Accessors; import org.springframework.data.annotation.CreatedBy; import org.springframework.data.annotation.CreatedDate; import org.springframework.data.annotation.LastModifiedBy; import org.springframework.data.annotation.LastModifiedDate; import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*; import java.time.LocalDateTime; import java.util.List;

@Data @AllArgsConstructor @NoArgsConstructor @Entity

public class User {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

private String account;

private String email;

private String phoneNumber;


private LocalDateTime createdAt;


private String createdBy;


private LocalDateTime updatedAt;


private String updatedBy;

}

UserRepositoryTest.java

package com.example.study.repository;

import com.example.study.StudyApplicationTests; import com.example.study.model.entity.User;

import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired;

import java.time.LocalDateTime; import java.util.Optional;

public class UserRepositoryTest extends StudyApplicationTests {

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

@Test
public void create(){
    User user=new User();
    user.setAccount("TestUser01");
    user.setEmail("TestUser@gmai.com");
    user.setPhoneNumber("010-1111-1111");
    user.setCreatedAt(LocalDateTime.now());
    user.setCreatedBy("TestUser01");


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

}

@Test

public void read(){ Optional user=userRepository.findById(2L);

    user.ifPresent(selectUser->{
        System.out.println("user:"+user);
    });

}

public void update(){

}

public void delete(){

}

}

에러메세지

Testing started at 8:09 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:22: 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:23: error: cannot find symbol user.setEmail("TestUser@gmai.com"); ^ symbol: method setEmail(String) 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.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:25: 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:26: error: cannot find symbol user.setCreatedBy("TestUser01"); ^ symbol: method setCreatedBy(String) location: variable user of type User 5 errors FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':compileTestJava'. Compilation failed; see the compiler error output for details.
  • Try: Run with --info or --debug option to get more log output. Run with --scan to get full insights.
  • Exception is: org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':compileTestJava' Caused by: org.gradle.api.internal.tasks.compile.CompilationFailedException: Compilation failed;

이런식으로뜨네요 그리고 위코드는 패캠애서 가져온거 그대로 넣은건데 안되네요;;; 똑같이 강의보면서 했거든요

1 답변

답변을 하려면 로그인이 필요합니다.

프로그래머스 커뮤니티는 개발자들을 위한 Q&A 서비스입니다. 로그인해야 답변을 작성하실 수 있습니다.

(ಠ_ಠ)
(ಠ‿ಠ)