一个完整的idea spring boot 项目及坑---1.lib

当项目需要的jar包在pom中无法通过manven直接下载时,我们需要在网上找到相应的jar包引人.遇到这类情况建议在根目录下建立lib文件夹来统一保管.

接下来在pom中添加

!--本地依赖-->
        <dependency>
            <groupId>ZXC</groupId>#随意填写
            <artifactId>ss</artifactId> #随意填写
            <version>1.0</version> 
          <scope>system</scope>
 <systemPath>${project.basedir}/lib/poi-3.14.jar</systemPath>
   </dependency>
大坑

若今后想要打包成jar包,上述的引用是不能够将外部jar包打包进项目的.需要在pom文件中<build>节点中加入下图中加下划线的部分.其中有个大坑.详情看图.

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <configuration>
                <fork>true</fork>
                <!-- spring-boot:run 中文乱码解决 -->
                <jvmArguments>-Dfile.encoding=UTF-8</jvmArguments>
            </configuration>
        </plugin>
    </plugins>

    <!--超级大坑,只能在将要打jar包时使用,可以把外部包大把进项目,但是!打包后一定要注销,否则运行项目会报Failed to auto-configure a DataSource的错误!!-->
    <resources>
        <resource>
            <directory>${project.basedir}/lib</directory>
            <targetPath>BOOT-INF/lib/</targetPath>
            <includes>
                <include>**/*.jar</include>
            </includes>
        </resource>
        <resource>
            <directory>src/main/resources</directory>
            <targetPath>BOOT-INF/classes/</targetPath>
        </resource>
    </resources>
</build>

另付下poijar包的下载,地址.此包是用来将list集合输出为excel表的.

http://maven.outofmemory.cn/org.apache.poi/poi/3.14/

猜你喜欢

转载自blog.csdn.net/ljxzdn/article/details/80223643