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 store SpringBoot MainApplication files

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

Share

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

This article introduces the relevant knowledge of "how to store SpringBoot MainApplication files". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Location of the MainApplication class file

There is a main program entry class when building a SpringBoot project.

The MainApp class must be placed in the root directory of the entire project, and Spring scans all Class under the package where the file is located when scanning for comments.

If other classes are placed higher than this class or other directory, they will not be scanned.

Import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.SpringBootApplication;/** * @ SpringBootApplication marks a main program class. This means that this is a SpringBoot application * / @ SpringBootApplicationpublic class ProMainApplication {public static void main (String [] args) {/ / make the SpringBoot application run SpringApplication.run (ProMainApplication.class,args);}} be sure to pay attention to the location of the startup class.

When we first come into contact with the spring-boot project, we may encounter the problem that the spring-boot project starts normally but accesses resources at 404.

At this point, we need to check the location of the startup class. Because the default scan location for @ SpringBootApplication is the same level directory and subdirectory where Application is located.

So, we're going to put the startup class, and controller,service... Wait for the bag to be put under the same bag.

This is the end of the content of "how to store SpringBoot MainApplication files". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

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