IntelliJ IDEA 如何引入本地 jar 包


通過添加Libraries的方式引入:

1、首先在根目錄下創建一個 libs 的目錄

2、打開 File -> Project Structure

 

3、單擊 Libraries  -> "+" -> "Java" -> 選擇我們導入的項目主目錄,點擊OK

 

4、注意:在彈出的方框中點擊“Cancel”,取消將其添加到Module中。

 

5、libs目錄創建成功,刪除目錄中添加進來的多余內容,重新添加需要的jar包

 

6、重新添加需要的jar包

 

7、引入jar包:Modules -> 項目 -> “Dependencies”,點擊“+” -> “Library”,將剛才創建成功的Library目錄加入

 

8、jar包導入成功!

 

9、如果要將引入的jar包打包到war中,需要在pom文件中添加以下配置+

<!-- 引用本地jar包 -->
<dependency>
    <groupId>com.aspose</groupId>
    <artifactId>aspose-words</artifactId>
    <version>16.8.0</version>
    <scope>system</scope>
    <systemPath>${pom.basedir}/libs/aspose-words-16.8.0-jdk16.jar</systemPath>
</dependency>
<dependency>
    <groupId>com.aspose</groupId>
    <artifactId>aspose-cells</artifactId>
    <version>8.5.2</version>
    <scope>system</scope>
    <systemPath>${pom.basedir}/libs/aspose-cells-8.5.2.jar</systemPath>
</dependency>
<dependency>
    <groupId>com.aspose</groupId>
    <artifactId>aspose-slides</artifactId>
    <version>15.9.0</version>
    <scope>system</scope>
    <systemPath>${pom.basedir}/libs/aspose.slides-15.9.0.jar</systemPath>
</dependency>

 

<!-- 將本地jar包打到war中 -->
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>
    <executions>
        <execution>
            <id>copy-dependencies</id>
            <phase>compile</phase>
            <goals>
                <goal>copy-dependencies</goal>
            </goals>
            <configuration>
                <outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/lib</outputDirectory>
                <includeScope>system</includeScope>
            </configuration>
        </execution>
    </executions>
</plugin>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM