通过添加Libraries的方式引入:

1、首先在根目录下创建一个 libs 的目录

idea如何导入jar包

2、打开 File -> Project Structure

3、单击 Libraries  -> "+" -> "Java" -> 选择我们导入的项目主目录,点击OK

idea如何导入jar包

idea如何导入jar包

4、注意:在弹出的方框中点击“Cancel”,取消将其添加到Module中。

5、libs目录创建成功,删除目录中添加进来的多余内容,重新添加需要的jar包

idea如何导入jar包

6、重新添加需要的jar包

idea如何导入jar包

idea如何导入jar包

idea如何导入jar包

7、引入jar包:Modules -> 项目 -> “Dependencies”,点击“+” -> “Library”,将刚才创建成功的Library目录加入

idea如何导入jar包

idea如何导入jar包

8、jar包导入成功!

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

idea如何导入jar包

<!-- 引用本地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>

idea如何导入jar包

idea如何导入jar包

<!-- 将本地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>
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。