spring boot工程下maven打包加载本地项目lib下的jar包的方法

1 更改dependency

        
            com.cloudera
            ImpalaJDBC41
            2.6.3
            system
            ${project.basedir}/src/main/resources/lib/ImpalaJDBC41-2.6.3.jar
        

2 更改plugins插件


	org.springframework.boot
	spring-boot-maven-plugin
	
		true
	

3 maven 打包

mvn -U clean package assembly:assembly -Dmaven.test.skip=true

4 运行java进程

java -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=70 -XX:+CMSParallelRemarkEnabled -XX:+HeapDumpOnOutOfMemoryError -jar /home/dev/work/core-data-board/target/core-data-board/lib/core-data-board-0.0.1.jar

完整的工程目录

spring boot工程下maven打包加载本地项目lib下的jar包的方法_第1张图片

下面是完整的pom文件配置



    4.0.0

    com.xeswx
    core-data-board
    core-data-board
    0.0.1
    Core Data Board

    
        2.1.5.RELEASE
        Greenwich.SR1
        UTF-8
        UTF-8
        1.8
        ${java.version}
        ${java.version}
        
        2.6
        2.6
        5.1.47
        com.xeswx.dw.coredataboard.CoreDataBoardApplication
        src/main/resources/assembly/package.xml
    


    
        
        
        
            org.mybatis.spring.boot
            mybatis-spring-boot-starter
            1.3.2
        
        
        
            mysql
            mysql-connector-java
            runtime
        

        
        
            com.alibaba
            druid
            1.1.10
        

        
        
            org.springframework.boot
            spring-boot-starter-aop
        

        
        
            org.apache.kylin
            kylin-jdbc
            2.6.2
        

        
        
            com.alibaba
            fastjson
            1.2.47
        
        
        
            commons-io
            commons-io
            2.4
        

        
        
            commons-httpclient
            commons-httpclient
            3.1
        


        
        
            org.springframework.boot
            spring-boot-starter-data-redis
        
        
            org.springframework.boot
            spring-boot-starter-redis
            1.0.1.RELEASE
        
        
            redis.clients
            jedis
            2.4.2
        

        
        
            org.springframework.session
            spring-session-data-redis
        
        
        
            org.springframework.security
            spring-security-web
            5.1.5.RELEASE
        

        
        
            org.springframework.boot
            spring-boot-starter-cache
        

        
            org.springframework.boot
            spring-boot-starter-web
        
        
            org.springframework.cloud
            spring-cloud-starter-netflix-eureka-client
        
        
            org.projectlombok
            lombok
            true
        
        
            
            
            
        
        
            org.springframework.boot
            spring-boot-starter-test
            test
        
        
            org.springframework.boot
            spring-boot-starter-actuator
        

        
            com.cloudera
            ImpalaJDBC41
            2.6.3
            system
            ${project.basedir}/src/main/resources/lib/ImpalaJDBC41-2.6.3.jar
        

    

    
        
            
                org.springframework.cloud
                spring-cloud-dependencies
                ${spring-cloud.version}
                pom
                import
            
            
                org.springframework.boot
                spring-boot-dependencies
                ${spring-boot.version}
                pom
                import
            
            
                mysql
                mysql-connector-java
                ${mysql.version}
            
        
    

    
        
            local-nexus-releases
            Local Nexus Repository
            http://59.151.109.88:8081/nexus/content/groups/public/
            
                true
                always
                fail
            
            
                true
                always
                fail
            
        
    

    
        ${project.artifactId}
        
            
                org.apache.maven.plugins
                maven-jar-plugin
                ${maven-jar-plugin.version}
                
                    
                        
                            
                            ${mainClass}
                            true
                            .
                        
                    
                
            
            
                maven-assembly-plugin
                ${maven-assembly-plugin.version}
                
                    
                    false
                    
                        
                        ${descriptorPath}
                    
                
                
                    
                        make-assembly
                        
                        package
                        
                            single
                        
                    
                
            
            
                org.springframework.boot
                spring-boot-maven-plugin
                
                    true
                
            
        
    

另外是一个网友分享的此类问题的几种处理方法,其中可以打包mvn -install先将依赖的本地jar包放入本地maven仓库
https://blog.csdn.net/do_you_like_van_game/article/details/96148321

其中的解决方案二:

将自己需要依赖的jar 打包到本地maven 库 (前提的配置好本地mvn)

打开cmd 窗口 输入, 红色的是依赖jar包位置,目的就是将其按照maven流程放入本地maven仓库

mvn install:install-file -Dfile=c:/xxx/xxx.jar -DgroupId=jeewx -DartifactId=jeewx-Dversion=1.0 -Dpackaging=jar
 

 

 

 

 

 

 

你可能感兴趣的:(maven)