1. Make sure that your project can be compiled and passed, install the java jdk environment and fill in the environment variables
2. Add SpringBootServletInitializer subclass override configure
This is very scammed, such as publishing PHP, or other things. Generally, the development is nothing different from the published ones. Spring has to add this. I didn't add it before, so I copied the war to the tomcat webapps directory.
package contacts;import org.springframework.boot.SpringApplication;import org.springframework.boot.SpringBootConfiguration;import org.springframework.boot.builder.SpringApplicationBuilder;import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;/** * Created by walle on 2018/3/20. */@SpringBootConfigurationpublic class ReadingListServletInitializer extends SpringBootServletInitializer { protected SpringApplicationBuilder configure(SpringApplicationBuilder builder){ return builder.sources(Application.class); }}Application is the original startup, which is to add a subclass of SpringBootServletInitializer.
3. Install Gradle
This is also quite tricky. Why does IntelliJ IDEA have no Release buttons as an editor? It has to be so troublesome. Search and download a Gradle to the local area, and then add Gradle environment variables to ensure that Gradle can be used in the cmd command line
4. Add apply plugin to build.gradle: 'war'
The default is jar, change to war
5. Open cmd in the project directory and execute gradle build
If it goes well, you can see a war file here. Everything is in the war package, including the dependency jar package, css, templates, etc. You can unzip it and view it yourself.
6. Install Tomcat
7. Copy the war file to the webapps directory of tomecat
Then start the tomcat service, and the war will be automatically decompressed, and then access the browser will be successful. It should be noted that war is placed anywhere. Modify the server.xml of tomecat's conf can also be specified to this directory. Adding this context to the host tag can be specified to the specific directory. War needs to be compressed by yourself. This way, accessing http://127.0.0.1:8090/contacts/ can also access your project.
The above is all the content of this article. I hope it will be helpful to everyone's learning and I hope everyone will support Wulin.com more.