我正在使用随附的Eclipse-Groovy插件的最新版本(2.8.0)groovy-all-2.1.5.jar.我将Guice添加到我的Groovy项目中,当我从Eclipse内部运行它们时,我在控制台输出中收到以下错误:
Caught: java.lang.NoClassDefFoundError: org/codehaus/groovy/runtime/typehandling/ShortTypeHandling
java.lang.NoClassDefFoundError: org/codehaus/groovy/runtime/typehandling/ShortTypeHandling
at net.me.myapp.utils.restclient.RestClient.<init>(RestClient.groovy:57)
at net.me.myapp.inject.UserServiceClientModule.configure(UserServiceClientModule.groovy:34)
at com.google.inject.AbstractModule.configure(AbstractModule.java:59)
at com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:223)
at com.google.inject.spi.Elements.getElements(Elements.java:101)
at com.google.inject.internal.InjectorShell$Builder.build(InjectorShell.java:133)
at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:103)
at com.google.inject.Guice.createInjector(Guice.java:95)
at com.google.inject.Guice.createInjector(Guice.java:72)
at com.google.inject.Guice.createInjector(Guice.java:62)
at net.me.myapp.UserServiceClient.<init>(UserServiceClient.groovy:37)
at net.me.myapp.UserServiceClient.main(UserServiceClient.groovy:45)
Caused by: java.lang.ClassNotFoundException: org.codehaus.groovy.runtime.typehandling.ShortTypeHandling
... 12 more
Run Code Online (Sandbox Code Playgroud)
根据这个答案,因为ShortTypeHandling直到2.3.x才添加.所以我现在想附加groovy-all-2.3.3.jar到我的Eclipse项目的类路径.
问题是我似乎没有编辑权限来更改库在Groovy Libraries库中使用的库.当我手动将2.3.3 JAR添加到我的构建路径时,我收到以下错误:
Caught: java.lang.ExceptionInInitializerError
java.lang.ExceptionInInitializerError
Caused by: groovy.lang.GroovyRuntimeException: Conflicting module versions. Module [groovy-all is loaded in version 2.1.5 and you are trying to load version 2.3.3
Run Code Online (Sandbox Code Playgroud)
我有什么选择?
我有一个关键的类路径顺序问题,因此我需要确保JAR 1在类路径中位于JAR 2之前.
有没有办法在Eclipse IDE中的GRADLE_DEPENDENCIES中强制执行此操作.
在打包应用程序(分发)期间如何实现相同的任何见解?
我知道这可能是这里发布的问题的重复.对不起.这是我为数据库连接编写的代码
try{
Class.forName("org.postgresql.Driver");
}
catch(ClassNotFoundException e)
{
e.printStackTrace();
}
try{
String URL = "jdbc:posgresql://localhost:5432/postgres";
String USER = "postgres";
String PASS = "postgres";
Connection conn = DriverManager.getConnection(URL, USER, PASS);
Statement st = conn.createStatement();
ResultSet rs = st.executeQuery("Select * from employee");
while(rs.next()){
System.out.println(rs.getString(1));
}
}
catch(SQLException es){
es.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)
运行此代码时,我得到以下异常:
java.sql.SQLException: No suitable driver found for jdbc:posgresql://localhost:5432/postgres
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at ManageEmployee.main(ManageEmployee.java:60)
Run Code Online (Sandbox Code Playgroud)
我在eclipse中构建了这个项目并添加了外部jar的postgres
如果它可能有帮助,这是.classpath文件
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6">
<attributes>
<attribute name="owner.project.facets" value="java"/>
</attributes> …Run Code Online (Sandbox Code Playgroud) 我用日食。我只是将两个jar添加到我的项目中,作为库> Add external jar。如下图所示,该文件夹中的所有其他jar都作为引用库进入我的项目。如何删除它。这些真的需要吗?编译后,应用程序jar文件的大小比我预期的大得多。
工具提示显示-from class path of .jar
我添加lombok到我的java项目中eclipse.它要求我在eclipse.ini文件中添加最后两行vmargs.
-showlocation
-vm
/home/$USER/JavaSE8/jdk1.8/bin/java
-startup
plugins/org.eclipse.equinox.launcher_1.3.0.v20140415-2008.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.gtk.linux.x86_64_1.1.200.v20150204-1316
-product
org.eclipse.epp.package.jee.product
--launcher.defaultAction
openFile
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
256m
--launcher.defaultAction
openFile
--launcher.appendVmargs
-vmargs
-Dosgi.requiredJavaVersion=1.6
-Xms500m
-Xmx2g
-Dorg.eclipse.swt.browser.XULRunnerPath=''
-javaagent:/home/$USER/eclipse/4.4-luna-SR2/lombok.jar
-Xbootclasspath/a:/home/$USER/eclipse/4.4-luna-SR2/lombok.jar
Run Code Online (Sandbox Code Playgroud)
我还添加lombok.jar了libraries(项目 - >属性 - >库),并lombok.jar在eclipse和JRE系统库(rt.jar,资源中)中的"订单和导出"选项卡(项目 - >属性 - >订单和导出)中移至最顶层.罐子等等都在下面lombok.jar.我对lombok主类的加载顺序感到困惑:
当eclipse启动时,Bootstrap类加载器加载应该在JRE的目录下的所有JDK类.(但是由于我已经lombok.jar在Order和Export中向上移动,在JRE系统库之上,将在之后加载rt.jar lombok.jar.大部分都不是吗?因为无论什么东西都应该首先加载bootstrap库!)
由于我们还重新定义了bootstrap classpath使用-XBootstrapClasspath选项,因此将加载lombok.jar Bootstrap Classloader.
之后Extensions classloader加载JRE的lib\ext目录中的类.
然后System-Classpath classloader加载CLASSPATH环境变量指定的所有类和jar(此加载是否考虑了Order and Export …
不时,Eclipse(Indigo)抱怨我的项目中的某些课程cannot be resolved to a type.即使它在弹出列表中显示类,单击import(参见图像)也不会添加import语句!即使我手动添加它,它也无法识别它(并强调导入包).
我在文档中看到的所有说明如何通过 build.gradle 文件向 Eclipse 项目类路径添加条目的示例都太常见了。他们没有说如何添加条目:
<classpathentry exported="true", kind="con" path="GROOVY_SUPPORT"/>
Run Code Online (Sandbox Code Playgroud)
Doc或“Gradle Effective Implementation Guide”一书对于建议毫无用处
//closure executed after .classpath content is loaded from existing file
//and after gradle build information is merged
whenMerged { classpath ->
//you can tinker with the Classpath here
}
Run Code Online (Sandbox Code Playgroud) eclipse gradle gradle-eclipse eclipse-classpath build.gradle
我一直试图修复这个错误,因为我无法编译任何项目,因为我的项目代码使用的任何东西都是sdk的一部分,在eclipse中出现错误.我试过移动我的工作区文件夹,删除sdk和eclipse文件夹,然后用新下载的文件夹替换它们.但我一直得到同样的错误.

以下是"Android SDK Content Loader"错误的详细信息
parseSdkContent failed
Source attachment path '\Users\lincoln\Desktop\android\sdk\sources\android-19' for IClasspathEntry must be absolute
Run Code Online (Sandbox Code Playgroud)
以下是"为Android 4.4.2加载数据"错误的详细信息
Parsing Data for android-19 failed
Source attachment path '\Users\lincoln\Desktop\android\sdk\sources\android-19' for IClasspathEntry must be absolute
Run Code Online (Sandbox Code Playgroud) eclipse ×6
java ×4
classpath ×2
gradle ×2
android ×1
build.gradle ×1
buildpath ×1
classloader ×1
dependencies ×1
groovy ×1
jar ×1
jdbc ×1
lombok ×1
m2eclipse ×1
maven ×1
parsing ×1
postgresql ×1
sdk ×1