Controller Mapping Issue By Package Structure While configuring querydsl-jpa initial setup, Only White Label Page Shown
Table of contents
- #Foreword
- 1.Possible Cause : Spring Boot Application Class Missing - (O)
- 2.Possible Cause : Incorrect Package Structure <- I suspected this but... (O)
- 3.Possible Cause : Missing Dependencies - Spring Web (O)
- 4.Possible Cause : application.yml or application.properties Misconfiguration
- #Still can't,,, why?
- #Solution by Package Structure
#Foreword
I guess HelloController is not being scanned by Spring Boot because of Package Structure
.................Let's see what's the real problem..............
(Controller can't successfully do mapping...................)
Some people would say It's very simple....
Frankly, I've never thought about this problem, and It didn't happen to me.
Although I have Controller with @RestController + @GetMapping("/hello), It shows nothing.
Hello Entity + QHello generated from Hello Entity.
This Spring Project is for Querydsl, and I finished verifying querydsl configuration by checking Qfile generated.
I thought everything goes well eventually,,,,,,,,,,,,,,,,,, ,,,, But, there's other problem.
To be honest, I feel so irritated.....................I haven't even yet started to do query dsl project since yesterday because of configuration problems.
Initially, My first problem was not to create Qfile successfully, but now GetMapping from HelloController isn't successfully mapped. I thought I could ignore this problem, because White Label Page means 8080 port successfully runs on. But, it came to my mind, it's related to a mapping problem.......So I want to know why this happens, I want to figure out 'Why'?........
If I can't diagnose this problem, I can't solve this if it happens again.
- It might not be related to code itself.
1.Possible Cause : Spring Boot Application Class Missing - (O)
Spring Boot application class annotated with @SpringBootApplication
.
2.Possible Cause : Incorrect Package Structure <- I suspected this but... (O)
: I suspected this, becuase I added additional package for Qfile like/src/main/generated
class path.
(Ensure your HelloController
class is successfully being scanned by Spring Boot.)
src
└── main
├── generated
│ └── entity
│ └── QHello
└── java
├── controller
│ └── HelloController.java
├── entity
│ └── Hello.java
└── study
└── querydsl
└── QuerydslApplication.java
3.Possible Cause : Missing Dependencies - Spring Web (O)
4.Possible Cause : application.yml or application.properties Misconfiguration
Solution: add server port : 8080
application.yml
server:
port: 8080
server.port=8080
Oh,, I didn't add application.yml
and I didn't add server.port=8080 on application.properties.
I changed it into application.yml and explicitly added server port, but,, didn't work.
#Still can't,,, why?
Hm... Frankly, I thought I'd better make progress with this error, but I don't think it's a good way to overlook this simple problem......
What's more, Although Whitelabel Error Page is also successful sign for Spring Web Server, which means 8080 port successfully runs on, the reason Controller can't work well must be because of a mapping issue.
Initially, I thought it's related to package structure.
Let's get back to the Package Structure...
In some cases, I added @RequestMapping
but,, same White Label error With @GetMapping
#Investigate Package Structure again.
Ah............... Perhaps.................................................?
#Solution by Package Structure
querydsl -> /src/main/generated
controller and entity
should be below at study.querydsl package
..............looking below
src
└── main
├── generated
│ └── entity
│ └── QHello
└── java
|
└── study
└── querydsl
└── QuerydslApplication.java
├── controller
└── HelloController.java
├── entity
└── Hello.java
Success.......................................
#Admittedly,
Admittedly, I am really ashamed to admit that I couldn't diagnose this simple problems........maybe it's my mistake or something else,,,, but I think this comes from my lack of skills....... Consequently, Trying to troubleshoot was my good decision,,,,Thanks to this, I can easily notice what's problem.
It's because I've been obsessed with Qfile class and filepath, I've never imagined this can cause problems.....