透過新增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>