Inflearn brand logo image

인프런 커뮤니티 질문&답변

작성자 없음

작성자 정보가 삭제된 글입니다.

실전! 스프링 부트와 JPA 활용1 - 웹 애플리케이션 개발

springboot에서 controller를 못찾는?것같아요 에러메세지 없고 url주소로 가면 whitelabel error page가 뜹니다...왜이럴까요 ㅜㅜ

해결된 질문

작성

·

5K

0

실행후에 index.html로 가서 index페이즈는 잘 나타납니다

그이후 a링크의 localhost:8080/board로 들어가면 whitelable error page가 나옵니다.

controller,spring폴더만들어서 게시판 만들어도 (아래 캡쳐) 같은 whitelable error page가 나옵니다.

오류메세지도 없고 controller System.out.println 메세지도 안뜹니다... 

이뜻은 controller를 못찾는다는 건가요?

제가 어느부분을 잘못한지 모르겠어요...

혹시나 yml파일 올려보니다.

spring:
datasource:
url: jdbc:h2:tcp://localhost/~/springBoard
username: sa
driver-class-name: org.h2.Driver

jpa:
hibernate:
ddl-auto: create
properties:
hibernate:
# show_sql: true
format_sql: true

logging:
level:
org.hibernate.SQL: debug
org.hibernate.Stype: trace

이건 build.gradle 입니다..

plugins {
id 'org.springframework.boot' version '2.4.0'
id 'io.spring.dependency-management' version '1.0.10.RELEASE'
id 'java'
}
group = 'SpringBorad.portFolio'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'org.springframework.boot:spring-boot-starter-web'
compileOnly 'org.projectlombok:lombok'
runtimeOnly 'com.h2database:h2'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
test {
useJUnitPlatform()
}


답변 2

2

네! 해결되었습니다. 감사합니다.

1

김영한님의 프로필 이미지
김영한
지식공유자

안녕하세요. 눕눕님

범인 찾았습니다^^

SpringBootApplication의 위치가 중요합니다.

SpringBootApplication이 있는 곳과 같은 패키지 이거나 그 하위 패키지만 스프링 부트가 자동으로 컴포넌트 스캔을 해서 인식합니다.

따라서 패키지 구조를 다음과 같이 만들어주세요.

myapp

myapp.board

myapp.contorller

그리고 SpringBootApplication의 위치를 myapp에 위치해주세요.

추가로 자바 패키지명 관례는 모두 소문자를 쓰는 것입니다^^

감사합니다.

작성자 없음

작성자 정보가 삭제된 글입니다.

질문하기