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

发布于 2024-11-06 04:08:55 字数 1852 浏览 4 评论 0原文

这是我的 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 is my 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>

Output:

$ 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]
...

Why this class in not in classpath?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

十年不长 2024-11-13 04:08:55

感谢这篇文章我发现了如何解决问题:

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

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

Thanks to this post I found out how to solve the problem:

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

I can't understand why it doesn't work through class loader...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文