mvn服务器使用阿里OSS或者相关服务打包失败情况解决

93 阅读1分钟

mvn服务器使用阿里OSS或者相关服务打包失败情况解决

后台是springside的服务器,最近接入阿里的OSS存储服务,添加阿里的jar包到pom.xml文件中之后,打包就出现了错误,添加如下:
在pom.xml中添加:

<dependency>
    <groupId>com.aliyun.oss</groupId>
    <artifactId>aliyun-sdk-oss</artifactId>
    <version>2.2.1</version>
</dependency>

然后开始打包,打包报错如下:

Failed to execute goal org.apache.maven.plugins:maven-enforcer-plugin:1.3.1:enforce (enforce-banned-dependencies) on project fanstudy: Some Enforcer rules have failed. Look above for specific messages explaining why the rule failed

查找了半天,最后发现阿里的jar包里面有commons-logging-1.2.jar,项目默认也有commons-logging-1.2.jar,导致打包冲突,所以需要排除一个,添加排除代码,配置如下:

<dependency>
    <groupId>com.aliyun.oss</groupId>
    <artifactId>aliyun-sdk-oss</artifactId>
    <version>2.2.1</version>
    <exclusions>
                <exclusion>
                    <groupId>commons-logging</groupId>
                    <artifactId>commons-logging</artifactId>
                </exclusion>
            </exclusions>
</dependency>

这样打包即可打包成功,使用其他阿里项目都可能也有此问题。