T
T
thatmaniscool2022-03-09 13:06:36
Spring
thatmaniscool, 2022-03-09 13:06:36

How to add package in spring project?

You need to make a small web server to send and receive data within the local network.
For convenience, I decided to put each solution in a separate package. But when you create a package and a class in it, nothing happens. How to solve this problem? Screenshot is attached.
62287bf7dc800142481731.jpeg
Error following

Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.

Wed Mar 09 19:06:16 YAKT 2022
There was an unexpected error (type=Not Found, status=404).

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Michael, 2022-03-09
@thatmaniscool

Controller is part of the application, so the Controllers package must be inside the application package
. This, of course, can be edited with spring annotations, but in general, SpringBootApplication looks for components (controllers, services, repositories, etc.) "down" from the application class. Accordingly, in your structure, it simply does not find the controller and does not create the controller bean.
Alternative - see ComponentScan annotation

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question