Eclipse使用总结
Eclipse使用总结
1、Eclipse中出现无法找到Maven包
的Libraries的标签栏下面看到添加的‘Maven Dependencies’。
2、在maven中可能存在如下的错误
错误:读取 C:\Documents and Settings\keju.wangkj\.m2\repository\com\sun\jdmk\jmxtools\1.2.1\jmxtools
-1.2.1.jar 时出错;error in opening zip file
错误:读取 C:\Documents and Settings\keju.wangkj\.m2\repository\com\sun\jmx\jmxri\1.2.1\jmxri-1.2.1.
jar 时出错;error in opening zip file
2 错误
5、Eclipse中的XML文件标签自动提示
8、受限的类访问
due to restriction on required library”; error message may be shown while developing Java projects in Eclipse IDE.
Error message is self-explanatory, some classes can not be loaded into the project sincerestriction rules are being imposed on those classes.
-
Windows -> Preferences -> Java -> Compiler -> Errors/Warnings -> Deprecated and restricted API -> Forbidden reference(access rules),
将error修改为warning - (Project) Properties -> Java Compiler -> Errors/Warnings
option under “Deprecated and restricted API” section in the dialog box. This option decides how to handle accessrules defined inside Eclipse. By default it is set to “Error” which causes
Eclipse to complain about references to any restricted classes. Choosing any other option (Warning or Ignore) will remove these error messages.
“Warning” or “Ignore” options will only hide the potential issue in the project, by allowing the project to use any classes ignoring predefined access rules. To completely resolve this
issue, analyze the project and located the use of restricted classes and take necessary actions (either remove those references or accessrules).
-> Errors/Warnings -> Deprecated and restricted API ->Deprecated API,选择上下面的2个Combo
Box(组合框),‘single use 。。’和‘Single overriding。。’
10、修改eclipse的jvm大小
11、Eclipse中的classpath
无法启动 JVM terminated. Exit code=-1 的解决办法
在网上找了一下,有人说是JAVA环境配置的问题,我想这不可能,因为以前一直用的好好的。有人说是JVM的问题,这个我刚刚换了一个,也不是这个问题,后来看来有人说是:eclipse.ini中内存设置过大的问题,虽然我不以为然,还是试了一下,以前我修改过内存设置,一直都好好的,之前eclipse.ini的配置如下:
-showsplash
com.genuitec.myeclipse.product
–launcher.XXMaxPermSize
512m
-vmargs
-Xms256m
-Xmx512m
-Duser.language=en
-XX:PermSize=256M
-XX:MaxPermSize=512M
现在修改了一下,-Xms256m改成-Xms128m,把Xmx512m 改为 Xmx256m,结果还真的好了,没想到居然是这样的小问题引起来的。
13、设置maven调试端口
14、Eclipse 中 drop to frame 的调试技巧
to re-enter the selected stack frame in the Debug View.
-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n
修改Tomcat的bin\catalina.bat,在里面加入set JAVA_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=7777
然后在Eclipse中选择debug,新建”Remote
Java Application,在port上写入7777,然后再启动Tomcat,打上断点就OK了。
第二种方法是安装Eclipse的Tomcat插件,网上很多地方可以下载,在Eclipse中使用Tomcat插件启动Tomcat,就可以直接打断点Debug了
删除掉C:\Documents and Settings\用户名\Application Data\Subversion\auth\svn.simple文件夹下的文件即可.
Application Data是一个隐藏的文件夹.
将<packaging>jar</packaging>修改为<packaging>pom</packaging>, 此时mvn eclipse:clean不会清理根下面的.classpath和.project文件。
删除Eclipse的workspace,
找到 eclipse\configuration\.settings\org.eclipse.ui.ide.prefs 文件
用记事本打开,找到
RECENT_WORKSPACES=D\:\\workspaces\\workspace7\nC\:\\Documents and Settings\\keju.wangkj\\workspace
将不用的workspace目录删掉就可以了
- -startup
- plugins/org.eclipse.equinox.launcher_1.1.1.R36x_v20101122_1400.jar
- --launcher.library
- plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.1.2.R36x_v20101222
- -product
- org.eclipse.epp.package.rcp.product
- --launcher.defaultAction
- openFile
- --launcher.XXMaxPermSize
- 256M
- -showsplash
- org.eclipse.platform
- --launcher.XXMaxPermSize
- 256m
- --launcher.defaultAction
- openFile
- -vmargs
- -Dosgi.requiredJavaVersion=1.5
- -Xms40m
- -Xmx512m
- -startup
- plugins/org.eclipse.equinox.launcher_1.1.1.R36x_v20101122_1400.jar
- --launcher.library
- plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.1.2.R36x_v20101222
- -product
- org.eclipse.epp.package.rcp.product
- --launcher.defaultAction
- openFile
- --launcher.XXMaxPermSize
- 128M
- -showsplash
- org.eclipse.platform
- --launcher.XXMaxPermSize
- 128m
- --launcher.defaultAction
- openFile
- -vmargs
- -Dosgi.requiredJavaVersion=1.6
- -Xms40m
- -Xmx256m
2. 重启
3. 删掉多余项目
4。 再将项目拷贝进来
- java.lang.NoClassDefFoundError: org.junit.runner.Runner
- at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
- at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:24)
- at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.<init>(JUnit4TestReference.java:32)
- at org.eclipse.jdt.internal.junit4.runner.JUnit4TestClassReference.<init>(JUnit4TestClassReference.java:25)
- at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:41)
- at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:31)
- at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:452)
- at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
- at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
- at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
这个异常是一个项目中存在多个Junit的jar,你需要检查当前项目下是否有两个junit.
[一般情况下只有一个]
还有一个重要的地方是,当前项目所依赖的项目中是否也存在Junit,如果依赖的项目Junit版本和当前项目的Junit版本不一致,那么恭喜你,你悲剧了,会发生如上错误。
可以通过在eclipse启动是加上 -showlocation 这个参数显示工作空间信息
如:eclipse.exe -showlocation
标题栏上会显示当前工作空间信息。这时我们可以区分正在使用的是哪一个Eclipse
参考:http://blog.csdn.net/zeuskaaba/archive/2009/07/25/4380026.aspx
31、干掉已经完成的todo
在eclipse中,ide会产生大量的// TODO,用于提醒程序员那些未完成的事情,通过Tasks视图可以查看到那些未完成的内容。代码已经完成,请删除之,这个写代码的好习惯。
Eclipse的 File -> Export(导出),在窗口中展开 General(常规) -> Perferences(首选项)–>Export all(全部导出)然后点击 NEXT。然后点击”Browse(浏览)”选择任意的一个路径,保存配置文件,然后点击”Finish”。