1
我有一个问题有点难以解释,但我会尽我所能去做。如果您不了解任何内容或需要更多信息,请随时提问。 :)Maven和java插件框架
我有一个java项目,使用java插件框架。这意味着我在项目的类路径中搜索具有特定结构的项目。 我有这个需要的结构,并包含在主体工程的pom.xml作为依赖这样的两个项目:
loader = ServiceLoader.load(ISomeInterface.class);
loader.iterator();
:
<dependency>
<groupId>package</groupId>
<artifactId>One</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>package</groupId>
<artifactId>Two</artifactId>
<version>1.0</version>
</dependency>
我通过的ServiceLoader这样的检索可用类
我的问题是,ServiceLoader.load调用只提供我的pom.xml中首先提到的项目。
有没有人做过类似的经历,或者可以帮助我解决这个问题?
由于提前, 洛里斯
在运行时都依赖关系存在,并且可以通过访问当前线程的Classloader? – hotzst
不,如果我使用eclipse运行我的应用程序,一切都像魅力一样。如果我使用maven构建项目,它只能找到在pom.xml中首先提到的项目。 有趣的是,两个项目的每个类都包含在最终的jar文件中。 – LorisBachert
也许是类加载器的问题?从构建中可以访问不同的类路径树。 > https://cwiki.apache.org/confluence/display/MAVEN/Maven+3.x+Class+Loading > http://stackoverflow.com/questions/4443345/maven-plugin-classloading > http ://trasahin.blogspot.de/2011/11/java-class-loader-and-maven-plugin.html 只是猜测... –