1. 程式人生 > 其它 >idea打jar包

idea打jar包

1、問題描述 

  我這邊是分為兩個專案 一個分為service 一個分為web 把兩個專案匯入到一個idea裡面 從而不分別啟動。

以我這邊為例子:把service打jar包到web中去

把下面的程式碼複製到service  (也就是你要打為jar包的專案)  pom檔案中

下面程式碼中的這個  <outputDirectory>../sz_smkt_web/src/main/webapp/WEB-INF/lib/</outputDirectory>

路改成你要打jar包的路徑

 <include>**/domain/*</include>

            <include>**/pojo/*</include>

            <include>**/*APProxy*.class</include>

這些是你要打包的檔案型別

 把下方程式碼複製進去

<plugins>

<plugin>

    <groupId>org.apache.maven.plugins</groupId>

    <artifactId>maven-jar-plugin</artifactId>

    <version>2.6</version>

    <configuration>

        <jarName>jar包名字</jarName>

        <includes>

            <include>**/domain/*</include>

            <include>**/pojo/*</include>

            <include>**/*APProxy*.class</include>

        </includes>

        <excludes>

            <exclude>*.pom</exclude>

        </excludes>

        <outputDirectory>../sz_smkt_web/src/main/webapp/WEB-INF/lib/</outputDirectory>

    </configuration>

</plugin>

<plugin>

    <groupId>org.apache.maven.plugins</groupId>

    <artifactId>maven-war-plugin</artifactId>

    <version>2.4</version>

</plugin>

<plugin>

    <groupId>org.apache.maven.plugins</groupId>

    <artifactId>maven-compiler-plugin</artifactId>

    <version>3.3</version>

    <configuration>

        <source>1.8</source>

        <target>1.8</target>

        <verbose>true</verbose>

        <encoding>UTF-8</encoding>

    </configuration>

</plugin>

<plugin>

    <groupId>org.apache.maven.plugins</groupId>

    <artifactId>maven-resources-plugin</artifactId>

    <version>3.1.0</version>

    <configuration>

        <encoding>UTF-8</encoding>

    </configuration>

</plugin>

</plugins>