전체 글
-
-
[SPRING] JdbcSQLIntegrityConstraintViolationException , DataIntegrityViolationException에러 일기 2022. 12. 20. 22:28
테이블에서 User(회원), Board(게시글), Comment(댓글) 간의 연관관계에서 낫던 에러이다. Board 테이블은 Comment 테이블과 연관되어 있는 상태이며, Board -> @OneToMany / Comment -> @ManyToOne 이다. Board에 연결된 Comment List에 저장된 객체가 있을 경우에 Board를 삭제하면 JdbcSQLIntegrityConstraintViolationException 에러가 나온다. 아마도 연결되어있는 Comment 객체가 남게 되기 때문에 위험신호를 주는 것 같다. 반대로 Comment는 삭제해도 되지 않을까 싶었지만 이것도 DataIntegrityViolationException 에러를 반환한다. 해결방법 기존에 Board 쪽에 @OneT..
-
[SPRING] java.lang.ClassNotFoundException: Could not load requested class : org.hibernate.dialect.MySQL5InnoDBDialectSpring Boot 2022. 12. 19. 17:01
H2 콘솔을 사용하다가 AWS에서 만든 DB RDS로 바꾸니 일어난 에러이다. 찾아보니 dialect라는 것이 '방언' 이라는 뜻을 가지고 있는데, MySQL이 JPA 방언을 인식하지 못하는 상황이 발생한 것이다. 원래는 따로 설정이 없어도 MySQL이 방언을 이해할 수 있었는데, 자바 버전이 올라감에 따라(현재 프로젝트 버전 3.0.0) 수동으로 설정을 해주지 않으면 방언을 이해하지 못하게 된 것 같다. application.properties에 아래 코드만 추가했을 때 에러가 발생했다. spring.datasource.url=jdbc:mysql://springboot-db.cxtctpbh0bfs.ap-northeast-2.rds.amazonaws.com:3306/myselectshop spring.d..
-
[SPRING] 공백과 NULL 확인할땐 StringUtils.hasText()Spring Boot 2022. 12. 14. 16:10
System.out.println(StringUtils.hasText(null)); // false System.out.println(StringUtils.hasText("")); // false System.out.println(StringUtils.hasText(" ")); // false System.out.println(StringUtils.hasText("A")); // true isBlank()와 혼동할 수 있는데, isBlack()는 문자열을 판단하기 때문에 null은 판단할 수 없다.
-
[SPRING] DI(의존성 주입)가 무엇이고, IoC 컨테이너는 어떻게 사용할까?Spring Boot 2022. 12. 12. 17:58
DI (의존성 주입) 의 이해 일반적인 구조의 한계 그동안 프로젝트 구조를 살펴보면, Controller 클래스에서 new Service를 만들고, Service 클래스에서 new Repository를 만들어 각각의 객체에서 함수를 만들어 불러오는 식으로 작업의 역할분담을 했다. 만약에 여기서 new Repository에 username, password를 파라미터로 전달받아 DB에 접속 시 사용해야 하는 기획으로 변경되었다면 어떻게 해야 변경이 되어야할까? // Controller에서 username과 password 전달 new Service("이재원", "123456") // Service에서 전달받은 값을 또다시 Repository에 전달 (username, password)-> new Repos..
-
[SPRING] Parameter 0 of constructor in 'A Controller' required a bean of type 'B Service' that could not be found.에러 일기 2022. 12. 7. 16:22
이해 안가는 애노테이션을 주석하고 하나씩 주석을 풀면서 실행 시키다가 아래와 같은 에러를 발견했다. Parameter 0 of constructor in com.practice.practicememo.controller.MemoController required a bean of type 'com.practice.practicememo.service.MemoService' that could not be found. service쪽 파일에 @Service 애노테이션을 추가해주니 해결되었다. 또는 Bean을 생성할 클래스에 @Component를 추가해주니 해결되었다. 자세히는 모르겠지만 우선은 @Controller, @Service, @Repository 세개가 의존관계인데, 그게 없으니 에러가 뜬 것 같..
-
[SPRING] Error creating bean with name 'memoRepository' defined in com.경로.경로 defined in @EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration: Not a managed type: class com.경로.경로에러 일기 2022. 12. 7. 15:43
@EnableJpaRepositories 을 선언했으면 repository에 테이블이 있어야 하는데 하나도 없는 상태여서 그런 것 같다. entity 폴더에서 @Entity를 선언해서 테이블을 추가해주니 에러가 사라졌다.