maven deploy上传文件到私服 神坑解决

maven deploy上传文件到私服 神坑解决

命令行使用命令

mvn deploy:deploy-file -DgroupId=com.sf -DartifactId=express -Dversion=2.1.1 -Dpackaging=jar -Dfile=E:\workplaces\java\SF-CSIM-EXPRESS-SDK-V2.1.1\SF-CSIM-EXPRESS-SDK-V2.1.1.jar -Durl=http://61.160.71.141:81/nexus/repository/maven-releases/ -DrepositoryId=maven-releases

或者

 mvn clean package deploy

如果报错403,Request Entity Too Large
原因:因为用了nginx代理,而nginx默认文件大小有限,所以需要设置nginx上传文件大小限制
解决方法:去nginx设置大小,然后重启nginx

client_max_body_size 200M;

如果报错401
原因:maven目录conf的setting.xml里没有配置认证,没有权限
解决方法:.m2 settings配置用户名密码,解决权限的问题(.m2具体你要去看你的maven配置File-settings-maven)

<server>
   <id>maven-releases</id>
   <username>admin</username>
   <password>admin123</password>
</server>

如果因为jar包里面有boot-inf,导致路径错误
解决方法:在build里面配置

<build>
    <finalName>${project.artifactId}</finalName>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <configuration>
                <executable>true</executable>
                <skip>true</skip>   // 就是这个
            </configuration>
        </plugin>
    </plugins>
</build>

此时引入依赖不报错了,运行的时候报错:
报错: non-compatible bean definition of same name and class [com.xxx.xxx.xx]】
原因:有相同的实现类名在不同的package目录下,也就是我引入的jar包中有和项目中有相同的实现类名,看了一下是jar的service包中有一个xxxService和项目中也有一个同名的xxxService,其实jar包中我并不需要使用service,我需要的仅仅只是client和entity这些,所有想到了只给部分打包
解决办法:只给需要的部分打包

<build>
        <finalName>${project.artifactId}</finalName>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <executable>true</executable>
                    <skip>true</skip>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-jar-plugin</artifactId>
                <executions>
                    <execution>
                        <id>client</id>
                        <goals>
                            <goal>jar</goal>
                        </goals><!-- 打包的后缀 -->
                        <phase>package</phase><!-- life的多个阶段 ,预打包 -->
                        <configuration>
                            <classifier>client</classifier>
                            <includes><!-- 引入 路径 -->
                                <include>**/clients/**</include>
                                <include>**/dto/**</include>
                                <include>**/enums/**</include>
                                <include>**/vo/**</include>
                                <include>**/entity/**</include>
                            </includes>
                            <excludes>
                                <exclude>**/service/**</exclude>
                                <exclude>**/utils/**</exclude>
                                <exclude>**/pcnotice/**</exclude>
                            </excludes>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

引用私服的该jar包:

<dependency>
    <groupId>com.xxx</groupId>
    <artifactId>xxx-service</artifactId>
    <version>2.0.8-RELEASE</version>
    <classifier>client</classifier>
    <exclusions>
        <exclusion>
            <groupId>*</groupId>
            <artifactId>*</artifactId>
        </exclusion>
    </exclusions>
</dependency>
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值