• 카테고리

    질문 & 답변
  • 세부 분야

    백엔드

  • 해결 여부

    미해결

질문있습니다..!

19.12.15 06:21 작성 조회수 441

0

강의 잘 보고있습니다,본문으로 들어가자면 똑같이 입력을하고 마지막이 테스트를 돌리면 JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default~ 이러한 경고메세지가 나오는데 뭐가문제일까요..?;

답변 4

·

답변을 작성해보세요.

1

제 기억으로는 스프링 부트 버전을 올리면서 JPA의 OSIV 기본 설정 값을 false로 바꾸자는 논의가 있었습니다. 그런데 그러면 하위 버전 호환성이 깨지면서 많은 문제를 야기할 거라서, 경고 메시지를 출력하는 걸로 이슈를 정리했습니다. 아마도 그것 떄문에 보여주는 경고성 메시지일 뿐이니 애플리케이션 자체가 문제는 없을겁니다. 다만 OSIV에 대해 공부를 하고 쓰신다면 더 좋겠죠.

0

김명우님의 프로필

김명우

질문자

2019.12.20

친절한 답변감사합니다^^ 말씀하신대로 OSIV에 대해 좀더 공부해보도록 하겠습니다ㅎㅎ

0

김명우님의 프로필

김명우

질문자

2019.12.17

답변감사합니다 경고메세지는 이러하고

JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning

코드는 이렇습니다

@Entity
public class Person {

@Id @GeneratedValue
private Long id;

private String name;

public String getName() {
return name;
}

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

public Long getId() {
return id;
}

public void setId(Long id) {
this.id = id;
}
}
public interface PersonRepository extends JpaRepository<Person,Long> {
}
@RestController
public class SampleController {

@GetMapping("/hello")
public String Hello(@RequestParam("id") Person person){
return "hello " + person.getName();
}
}
@Configuration
public class WebConfig implements WebMvcConfigurer {
}
@RunWith(SpringRunner.class)
@SpringBootTest
@AutoConfigureMockMvc
public class SampleControllerTest {

@Autowired
MockMvc mockMvc;
@Autowired
PersonRepository personRepository;
@Test
public void hello() throws Exception{
Person person=new Person();
person.setName("keesun");
Person savedPerson=personRepository.save(person);

this.mockMvc.perform(get("/hello")
.param("id",savedPerson.getId().toString()))
.andDo(print())
.andExpect(content().string("hello keesun"));
}

}

0

작성하신 코드랑 경고문을 복사해서 본문에 넣어주셨으면 좋았을거 같네요. 경고 자체는 별로 걱정이 안되는데 왜 저런 경고 메시지가 출력되는지는 코드를 봐야 알 수 있을거 같습니다.