How to use the Springboot project built-in Tomcat

Question: In the past, when we used the SSM framework, we deployed external tomcat. If you want to access the file, drag it directly to the root directory of the project. . If we need to put an apk file and let others download it, just put the apk under the project root directory, and the browser can download it through http://ip:port/projectName/xx.apk. Now we use spring boot for project development. Because springboot embeds tomcat, in order to facilitate deployment, we only need to run the project as a jar package in most cases. So there is a problem, how do we put this apk on the server, and others can download it through the browser?
1. Springboot project structure

|———main |———java———code|———src | | | | | | | |—— —Resources———Static resource configuration project | |———test |———pom.xml

Second, the structure of the jar package

 |———META-INF | |——libproject | | |———BOOT-INF| |——classes—— (class files under project structure java and files under resources)

Three What does classpath refer to? Classpath, as the name implies, is the path of classes. Before packaging, it refers to resources, and after packaging, it refers to classes.
Fourth, where to put the apk file, it can be accessed normally after packaging and deployment
The springboot configuration file provides us with the default static resource access path, of course, we can also modify it. The default path is the following four addresses. When we want to access static resources, we will find them one by one from the top to the next:

{"classpath:/META -INF/resources/", "classpath:/resources/", "classpath:/static/", "classpath:/public/"};

If you want to customize, use application. Settings in properties

spring.resources.static-locations=custom path

If we put the apk in any of the above folders, it can be accessed normally. What I do most often is to create a resources folder under resources, and then use http://ip:port/projectName/xx.apk to access it. As shown in the figure below
file

This way we can easily implement the browser Access the static resources in the jar, instead of installing tomcat, use the war package to run the project.

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 4742 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.