Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to solve the problem if SpringBoot can't scan Controller?

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

In this article Xiaobian for you to introduce in detail "SpringBoot scan can not Controller how to solve", the content is detailed, the steps are clear, the details are handled properly, I hope this "SpringBoot scan can not Controller how to solve" article can help you solve doubts, following the editor's ideas slowly in-depth, together to learn new knowledge.

SpringBoot rookie created a project and could not scan a series of Controller problems.

1.

two。

3.

4.

5.

6. Another way is to start the introduction to the service class, adding @ ComponentScan (basePackages= {"xxx.xxx.xx", "xxx.xxx.xx"}) to the fully qualified name of the package, which can be used for multiple

SpringBoot Custom controller failed to scan to

The SpringBoot custom controller route could not be found because the startup class and the custom Controller package are not in the same level directory.

Officially recommended location for application.java: the rest of the Bean and application.java are placed in the same package path, but this is not recommended.

The solution:

1. Put the self-built controller class in the same level directory of the startup class (this is not recommended).

2. Change the startup class @ RestController @ EnableAutoConfiguration annotation to @ SpringBootApplication.

3. Start the @ RestController @ EnableAutoConfiguration annotation and add the @ ComponentScan annotation.

There are two ways to configure annotations using springboot scanning:

1. The first kind

@ Controller @ EnableAutoConfiguration @ ComponentScan

2. The second kind

@ SpringBootApplication @ ComponentScan has read this article, "how to solve the problem when SpringBoot cannot be scanned by Controller". If you want to master the knowledge points of this article, you still need to practice and use it. If you want to know more about related articles, please follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report