Vue+springboot project deployment

Vue project deployment

1. Compress the project
After compression, upload it to the server and decompress it, and transmit the compressed package to prevent file damage.
2. Install front-end project dependencies

npm install --unsafe-perm --registry=https://registry.npm.taobao.org

3. Package project

npm run build

At the same time, you can also create the production environment package and the running environment package. If an error is reported, check whether the packaging method is not configured in your package.json file.
After the packaging is completed, a dist folder will be generated, copy the folder to the upper directory to prevent loss.
4. Configure nginx
The nginx agent defaults to its own index.html, which is the access page of nginx. We configure its nginx.conf file, first change the first line user to root

user root;

Reconfigure/address
Switch the original address to the dist directory

location / {
    
    
            root   /workespace/my_blog/dist/;
            index  index.html index.htm;
        }

5. Test access
At this time, you can enter your front-end Vue main page by accessing the server ip through the browser.

springboot project deployment

jar package deployment

1. Change the configuration file.
In pom.xml, set the jar package packaging method, and at the same time set the relevant information such as mysql and redis of your own server. If there is a configuration file address, remember to change it.
2. Package the backend project

mvn package

After packaging, a target folder will be generated. Similarly, copy the upper-level directory backup of the jar package in this folder.
3. Running in the background

nohup java -jar xxx.jar &

Running in the background allows us to access it even after we exit the command line.
After running successfully, we can directly access the interface of the project through the browser. If it cannot be accessed, a nohup.out log file will be generated after running. Let’s open the log file to see what is wrong. It may be that the port is occupied and cannot run , we can check the port information with netstat -ntpl, find the process and kill it, and run it again.
4. Test
At this time, our front-end and back-end projects have been deployed, and the data interaction of the webpage is no problem. Let's talk about war package deployment.

war package deployment

1. Change the configuration
Change the packaging method to war package, and add the coordinates to remove the tomcat that comes with springboot by default

<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
            <scope>provided</scope>
 </dependency>

2. Strip the built-in tomcat
and create another main file in the same level directory as xxxxApplication.java and inherit related classes. The return value is xxxApplication.class;

public class SpringBlogApplication extends SpringBootServletInitializer {
    
    
    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
    
    
        return builder.sources(BlogApplication.class);
    }
}

The modified and newly created files are then sent to the server.
3. Clean up the target
and switch to the address of the back-end project department

mvn clean

Clean up the target generated by our last package import.
4. Pack again

mvn package

The war package will be generated as follows
insert image description here

5. Stop the running of the jar package,
first query the process number of the jar package

ps -aux | grep java

Then kill the process
6. Run the war package,
copy the war package to the webapps folder under the tomcat installation path,
and then restart tomcat, and the outsourcing is completed.

Supongo que te gusta

Origin blog.csdn.net/qq_44660367/article/details/108897837
Recomendado
Clasificación