zoukankan      html  css  js  c++  java
  • 用idea打包

    idea的pom.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns="http://maven.apache.org/POM/4.0.0"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <parent>
            <artifactId>ciems-service-operation-management</artifactId>
            <groupId>com.gdtnx</groupId>
            <version>1.0.0-Alpha</version>
        </parent>
        <modelVersion>4.0.0</modelVersion>
    
        <artifactId>ciems-om-biz</artifactId>
        <properties>
            <start-class>cn.com.gdt.ciems.om.biz.OmApplication</start-class>
        </properties>
        <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-web</artifactId>
            </dependency>
            <dependency>
                <groupId>com.gdtnx</groupId>
                <artifactId>ciems-spring-boot-starter</artifactId>
                <version>1.0.1-Alpha</version>
            </dependency>
            <dependency>
                <groupId>mysql</groupId>
                <artifactId>mysql-connector-java</artifactId>
            </dependency>
            <dependency>
                <groupId>com.baomidou</groupId>
                <artifactId>mybatis-plus-boot-starter</artifactId>
                <version>${mybatis-plus.version}</version>
            </dependency>
    
            <dependency>
                <groupId>com.baomidou</groupId>
                <artifactId>mybatis-plus-generator</artifactId>
                <version>${mybatis-plus.version}</version>
            </dependency>
    
            <dependency>
                <groupId>org.freemarker</groupId>
                <artifactId>freemarker</artifactId>
            </dependency>
    
            <dependency>
                <groupId>com.zaxxer</groupId>
                <artifactId>HikariCP</artifactId>
            </dependency>
            <dependency>
                <groupId>commons-collections</groupId>
                <artifactId>commons-collections</artifactId>
                <version>3.2.2</version>
            </dependency>
            <dependency>
                <groupId>commons-codec</groupId>
                <artifactId>commons-codec</artifactId>
                <version>1.10</version>
            </dependency>
            <dependency>
                <groupId>org.apache.poi</groupId>
                <artifactId>poi</artifactId>
                <version>3.14</version>
            </dependency>
    
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-starter-openfeign</artifactId>
            </dependency>
            <dependency>
                <groupId>com.gdtnx</groupId>
                <artifactId>ks-api</artifactId>
                <version>0.0.1-Alpha</version>
            </dependency>
        </dependencies>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
                    <configuration>
                        <mainClass>${start-class}</mainClass>
                    </configuration>
                    <executions>
                        <execution>
                            <goals>
                                <!--可以把依赖的包都打包到生成的Jar包中-->
                                <goal>repackage</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    </project>

    红色字体为打包必须依赖的:

    注:如果是使用普通的maven编译器,(就不会要求指定mainClass类)那build标签应该这样写:

    <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <configuration>
                        <source>1.8</source>
                        <target>1.8</target>
                        <encoding>${project.build.sourceEncoding}</encoding>
                    </configuration>
                </plugin>
            </plugins>
        </build>

    如果是该包上传到自己的私服那么需要在pom.xml文件中加入:

    <distributionManagement>
            <repository>
                <id>nexus-releases</id>
                <name>Nexus Release Repository</name>
                <url>http://xxxx:10890/nexus/content/repositories/releases/</url>
            </repository>
        </distributionManagement>

    接下来,在idea里打包,如果是maven父子模块项目,那么在打包时为了防止子模块之间的依赖关系,需要打包父模块的pom.xml文件,具体方式见下图:ciems-service-operation-management就是父模块

    生成的jar包在启动的时候,执行java -jar 命令时,有点时候会因为utf-8编码问题报错,所以为了解决报错,需要执行:

     java -Dfile.encoding=utf-8 -jar springboot服务 
  • 相关阅读:
    DOS命令收集
    iis6配置支持.net4.0
    正则表达式限制文本框
    剖析XML(第一讲)
    DataTime.ToString("xx") 转换
    .net面试题大汇集
    django学习笔记(一)
    django学习笔记(一)
    django学习笔记(二)
    django学习笔记(二)
  • 原文地址:https://www.cnblogs.com/zhangshitong/p/12210098.html
Copyright © 2011-2022 走看看