gpt4 book ai didi

java - 为什么类不在 gmaven-plugin 脚本中的类路径中?

转载 作者:行者123 更新时间:2023-11-30 11:54:02 24 4
gpt4 key购买 nike

这是我的pom.xml:

<project>
[...]
<build>
<plugins>
<plugin>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>gmaven-plugin</artifactId>
<version>1.3</version>
<executions>
<execution>
<phase>generate-test-resources</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<classpath>
<element>
<groupId>hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>1.8.0.10</version>
</element>
</classpath>
<source>
Class.forName("org.hsqldb.jdbcDriver")
</source>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

输出:

$ mvn test
[INFO] Scanning for projects...
...
[INFO] --- gmaven-plugin:1.3:execute (default) @ foo ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.866s
[INFO] Finished at: Sun May 08 17:53:13 PDT 2011
[INFO] Final Memory: 7M/1531M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.gmaven:gmaven-plugin:1.3:execute
(default) on project foo: java.lang.ClassNotFoundException:
org.hsqldb.jdbcDriver -> [Help 1]
...

为什么这个类不在类路径中?

最佳答案

感谢this post我找到了解决问题的方法:

import org.hsqldb.jdbcDriver
def driver = new jdbcDriver()

我不明白为什么它不能通过类加载器工作...

关于java - 为什么类不在 gmaven-plugin 脚本中的类路径中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5931456/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com