분류 전체보기
(41)
JPA Entity를 JSON으로 변환할 때 발생할 수 있는 문제점과 해결방법
이번에 프로젝트를 진행하면서 엔티티를 json으로 변환 후에 view로 전달해주는 과정에서 문제가 발생했었습니다. 일단 결론부터 말씀드리자면 DTO를 따로 만들어서 서비스에서 엔티티 대신 DTO를 리턴 해준 뒤 Json으로 변환 해줬습니다. 1. 무한 참조 루프 Entity를 JSON으로 변환을 했더니 에러가 발생했습니다. org.codehaus.jackson.map.JsonMappingException: Infinite recursion (StackOverflowError) 이런 에러 메시지가 나왔는데 무슨 이유 인가 하니 엔티티 간의 관계 설정을 A -> B -> C -> A 이런 식으로 참조 해줬는데 무한루프가 발생해서 생기는 문제였습니다. 해결 방법으로는 참조 : https://stackoverf..
JPA
2019. 2. 27. 18:42
[Spring Security] loadUserByUsername(String username)에서 username이 empty일 때
스프링 시큐리티를 이용해서 로그인을 하는데 public class MemberDetailsService implements UserDetailsService { public final MemberService memberService; @Override @Transactional(readOnly = true) public UserDetails loadUserByUsername(String email) throws UsernameNotFoundException {loadUserByUsername 메소드의 파라미터 email의 값이 넘어오질 않았다.바로 구글에 loaduserbyusername username empty를 치니까 역시나 나같은 사람들이 많았고 https://stackoverflow.com/q..
Spring
2019. 1. 18. 16:27
리액트 에러 : This git repository has untracked files or uncommitted changes:
컴포넌트 스타일링을 하기위해서 $ yarn eject를 입력 했더니 이런 에러가 발생하였습니다.yarn run v1.12.3 $ react-scripts eject ? Are you sure you want to eject? This action is permanent. Yes This git repository has untracked files or uncommitted changes: src/App.css D src/App.js D src/App.test.js D src/index.css D src/logo.svg Remove untracked files, stash or commit any changes, and try again. error Command failed with exit c..
React
2018. 12. 12. 15:10
[Error] JPA를 이용한 테이블 생성후 외래키 있는 테이블 insert할 때 에러 (MyISAM , InnoDB)
create table wishlist ( member_id bigint not null, product_id bigint not null, primary key (member_id, product_id) ) engine=MyISAM alter table wishlist add constraint FKqchevbfw5wq0f4uqacns02rp7 foreign key (product_id) references product (id) 스푸링부트에서 JPA를 이용해서 이렇게 테이블을 선언해주고 외래키를 주었을 때product에 row가 아무것도 없음에도 불구하고 wishlist에서는 insert가 추가됩니다.(원래는 product_id가 product의 id를 외래키로 받기때문에 생성되면 안됩니다.)이유는 ..
Spring
2018. 12. 8. 15:52