eclipse 打包springboot成jar

2021-05-30 08:00

阅读:377

标签:soc   生产   pat   eclipse   clean   parent   resources   model   ebe   

因为springboot到生产环境是在部署到jar或者war,推荐用jar比较方便

如下pom.xml


         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    4.0.0
    springboot-websocket
    0.0.1springboot-websocketSpringBoot系列——WebSocketorg.springframework.boot
        spring-boot-starter-parent
        2.1.0.RELEASEorg.springframework.boot
            spring-boot-starter
        org.springframework.boot
            spring-boot-starter-web
        org.springframework.boot
            spring-boot-starter-test
            testorg.projectlombok
            lombok
        org.springframework.boot
            spring-boot-devtools
            trueruntimeorg.springframework.boot
            spring-boot-starter-websocket
        org.springframework.boot
            spring-boot-starter-thymeleaf
        org.java-websocket
Java-WebSocket
1.3.8springbootWebSocketsrc/main/java**/*.xmlsrc/main/resourcestrueorg.springframework.boot
                spring-boot-maven-plugin
            
                    maven-resources-plugin
                    utf-8true

主要注意下:


                    maven-resources-plugin
                    utf-8true
步骤:
1。选中项目,右击run as 顺序运行maven clean再maven install
2.打包成功之后,可以看到[INFO] BUILD SUCCESS ; 得到springbootWebSocket.jar包里有相关引用的jar
3.运行java -jar springbootWebSocket.jar
打包时注意:
1。不要在pom.xml引用关联外部的子模块或者父模块 2。因本项目使用websocket,在使用类SpringbootWebsocketApplicationTests测试时,
加上@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
package cn.huanzi.qch.springbootwebsocket;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class SpringbootWebsocketApplicationTests {

    @Test
    public void contextLoads() {
    }

}

 

eclipse 打包springboot成jar

标签:soc   生产   pat   eclipse   clean   parent   resources   model   ebe   

原文地址:https://www.cnblogs.com/fuanyu/p/14754613.html


评论


亲,登录后才可以留言!