比如我在项目中用到了shiro,然后我添加了shiro的dependency,可以看到在shiro-core中又依赖了commons-beanutils。这时我用了commons-beanutils中的类时,运行时报错class not found,必须重新添加commons-beanutils的依赖才能使用,不知道怎么看这种传递的依赖是不是有效,下面是shiro-core.pom文件,麻烦给我分析下
project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-root</artifactId>
<version>1.2.3</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>shiro-core</artifactId>
<name>Apache Shiro :: Core</name>
<packaging>bundle</packaging>
<build>
<plugins>
<!-- collect the test classes so they can be referenced by other modules -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>org.apache.shiro.core</Bundle-SymbolicName>
<Export-Package>org.apache.shiro*;version=${project.version}</Export-Package>
<Import-Package>
org.apache.shiro*;version="${shiro.osgi.importRange}",
org.apache.commons.beanutils*;resolution:=optional,
*
</Import-Package>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
</dependency>
<!-- For Java 1.4 and below only: - ->
<dependency>
<groupId>backport-util-concurrent</groupId>
<artifactId>backport-util-concurrent</artifactId>
</dependency>
-->
<!-- Test dependencies -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- JDBC Realm tests: -->
<dependency>
<groupId>hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。
不应该这样啊,确定你用的时候已经将相关包加在library下了吗谢谢,刚才找到问题了,原来shiro依赖的beanutils的版本是1.8.3,我自己添加的beanutils的版本是1.9.2,里面又依赖了commons-cellections,1.8.3里面没有commons-collections,还是看错误信息不仔细。。。
clear
然后重新install检查包是否冲突
没下载下来吧maven有个命令可以检查所有依赖的,不过我忘记是啥了