How to use springboot project built elegant tomcat

Question : In the past, when we use the framework of the SSM are deployed through an external tomcat, if you want to access files directly onto the root directory of the project the following can be. If we need to put a apk file, and then let others to download, simply apk into the project root directory, browser via http: // ip: port / projectName / xx.apk to download. Now use the spring boot project development, due springboot embedded tomcat, in order to facilitate the deployment, so in most cases we only need to run the project labeled jar package. This presents a problem, how do we put this apk on the server, others to download via the browser it?
A, springboot project structure

                 |———main  |———java———代码
        |———src  |       |
        |       |        |
        |       |        |———resources———静态资源配置
project |       |———test
        |———pom.xml

Second, the structure of the labeled jar package

        |———META-INF
        |          |——lib
project |          |
        |———BOOT-INF|
                    |——classes——(项目结构java下面的class文件和resources下面的文件)

Three, where classpath refers to the
classpath definition, is the class path, refers to the pre-packaged resources, after packaging refers to classes.
Fourth, where the apk file on the deployment package can access
springboot profile provides a default static resource access path for us, of course we can also be modified. The default path for these four addresses, when we want to access static resources will take down an address from an address to look for:

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

If you want to customize, then set the application.properties

spring.resources.static-locations=自定义路径

We apk into a folder in any of the above can be normal access to. What I usually do it is in the following resources to build a resources folder, and then use the http: // ip: port / projectName / xx.apk to visit. As shown below
file

In this way we will be able to easily access the browser jar static resources, and without installing tomcat, in the form of war package to run the project slightly.

Guess you like

Origin www.cnblogs.com/zhixie/p/11612328.html