我使用Hello RCP框架使用RCP框架创建了一个示例插件应用程序。然后,我将项目转换为Maven项目" configure"选项。我需要一个mysql连接器来执行一些db操作;为此,我在pom.xml文件中添加了依赖项。
构建应用程序后,它可以创建maven依赖文件夹并放置所需的mysql jar。但是,当我运行应用程序时,它说它无法找到Driver类。 Maven Dependency文件夹中的jar文件中没有错误。如果我手动将它放在构建路径中,它的工作正常。
每当我创建一个示例JAVA应用程序并将其转换为maven项目并添加这些依赖项时,它的工作正常。仅适用于插件项目,它无法找到所需的罐子。
以下是我的pom.xml的内容
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.sample.plugin</groupId>
<artifactId>com.sample.plugin</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>maven-plugin</packaging>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.4</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.18</version>
<scope>Compile</scope>
</dependency>
</dependencies>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
//错误消息
在连接class1中:
java.lang.ClassNotFoundException:com.mysql.jdbc.Driver 错误:无法加载驱动程序类! 在org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:513) 在org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:429) 在org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:417) 在org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107) at java.lang.ClassLoader.loadClass(ClassLoader.java:358) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:190) 在com.sample.plugin.DButil.getConnection(DButil.java:25) 在com.sample.plugin.Application.start(Application.java:20) 在org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196) 在org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110) 在org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79) 在org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344) 在org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) 在org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622) 在org.eclipse.equinox.launcher.Main.basicRun(Main.java:577) 在org.eclipse.equinox.launcher.Main.run(Main.java:1410) 在org.eclipse.equinox.launcher.Main.main(Main.java:1386) 拿起_JAVA_OPTIONS:-Xmx512M
答案 0 :(得分:0)