在资源管理器中打开Eclipse当前文件所在目录

eclipse_file_open_in_explorer.png

在Eclipse文件界面,按快捷键Alt+Shift+W,打开的上下文菜单,点击System Explorer即可打开当前文件所在目录,并将焦点定位到当前文件名。如果还想快一点打开,可以在Windows-Preferences-Keys里面搜索Show in (System Explorer), 在Binding里面绑定你的快捷键,我这里绑定的是Ctrl+E,这样直接在当前文件界面按Ctrl+E即可打开文件目录。

eclipse_preference_keys_show_in_system_explorer.png

jxl解析Excel报错:Cannot read drop down range Unrecognized token 60

Warning:  Cannot read drop down range Unrecognized token 60
java.lang.NullPointerException
  at jxl.biff.DataValiditySettingsRecord.getFirstColumn(DataValiditySettingsRecord.java:238)
  at jxl.read.biff.SheetReader.read(SheetReader.java:913)
  at jxl.read.biff.SheetImpl.readSheet(SheetImpl.java:650)
  at jxl.read.biff.WorkbookParser.getSheet(WorkbookParser.java:249)
  at com.tunps.platform.util.jxExcelMain(parseExcel.java:93)
  at org.apache.jsp.pages.Import_jsp._jspService(Import_jsp.java:190)
  at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)

用Jxl解析Excel出现这个问题。原因是Excel的数据有效性有问题,如图:

excel_validation.jpg

这个字段使用了其他电脑上获取的下拉选项,在我电脑上没有此选项文件,所以数据有效性是有问题的。我们可以通过这段代码来去掉jxl对Excel数据有效性的验证:

WorkbookSettings workbooksetting = new WorkbookSettings();
workbooksetting.setCellValidationDisabled(true);
Workbook wb = Workbook.getWorkbook(is,workbooksetting);

到此问题解决。但是我的这个项目已经把解析Excel的类封装成了jar,没有办法修改Java源代码。所以只能将Excel的有效性去掉再上传解析Excel文件。

在WPS内的去掉有效性操作是:数据 -- 有效性 -- 设置 -- 允许 -- 任何值 -- 勾选对所有同样设置的其他所有单元格应用这些设置 -- 确定。

在Excel中去掉有效性的操作是:数据 -- 数据验证 -- 数据验证 -- 允许 -- 任何值 -- 勾选对所有同样设置的其他所有单元格应用这些设置 -- 确定。

SQL Server死锁造成页面卡顿

原因是访问了数据库,做了数据库增删改操作,但是最后没有关闭数据库连接,造成之前的操作死锁。解决办法,在SSMS里面查看死锁的进程:

--查看死锁进程
select distinct 'kill' + ' ' + cast(request_session_id as varchar(200) ) + ';'
from   sys.dm_tran_locks where resource_type='OBJECT'

然后运行输出的内容,比如:

kill 60;
kill 61;

最后在业务代码的最后finally内关闭数据库连接:

conn.close();

Maven duplicate declaration of version

[INFO] Scanning for projects...
[WARNING] 
[WARNING] Some problems were encountered while building the effective model for cn.com.etianan.ebusiness:online:war:0.0.2-SNAPSHOT
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: cn.com.etianan.ebusiness:basicBizInfo:jar -> duplicate declaration of version (?) @ line 197, column 15
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: cn.com.etianan.ebusiness:claimService:jar -> duplicate declaration of version (?) @ line 250, column 15
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: cn.com.etianan.ebusiness:productDirectory:jar -> duplicate declaration of version (?) @ line 254, column 15
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: cn.com.etianan.ebusiness:permission:jar -> duplicate declaration of version (?) @ line 279, column 15
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: cn.com.etianan.ebusiness:payment:jar -> duplicate declaration of version (?) @ line 287, column 15
[WARNING] 'build.plugins.plugin.(groupId:artifactId)' must be unique but found duplicate declaration of plugin org.mortbay.jetty:maven-jetty-plugin @ line 360, column 12
[WARNING] 
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING] 
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING] 
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building online 0.0.2-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] Downloading: http://localhost:8081/nexus/content/groups/public/org/apache/maven/plugins/maven-clean-plugin/2.5/maven-clean-plugin-2.5.pom
[INFO] Downloading: http://maven-beabuild-plugin.googlecode.com/svn/maven2/releases/org/apache/maven/plugins/maven-clean-plugin/2.5/maven-clean-plugin-2.5.pom
[INFO] Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-clean-plugin/2.5/maven-clean-plugin-2.5.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1:10.535s
[INFO] Finished at: Tue Dec 31 11:21:09 GMT+08:00 2013
[INFO] Final Memory: 2M/4M
[INFO] ------------------------------------------------------------------------
[ERROR] Plugin org.apache.maven.plugins:maven-clean-plugin:2.5 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-clean-plugin:jar:2.5: Could not transfer artifact org.apache.maven.plugins:maven-clean-plugin:pom:2.5 from/to nexus (http://localhost:8081/nexus/content/groups/public): Connection to http://localhost:8081 refused: Connection refused: connect -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException

原因是因为出现了重复的dependency节点。删除重复节点,留下一个即可。

Tomcat启动超时 unable to start within 45 seconds

当启动tomcat时候出现

Server Tomcat v6.0 Server at localhost was unable to start within 45
seconds. If the server requires more time, try increasing the timeout
in the server editor.

tomcat_time_out.jpg

的错误,那表示你的tomcat启动超时了,有时候你重新启动下就好了,但有时需要重新启动很多次,如果你不想这样的话,你只需修改下tomcat的启动 时间就行了,步骤如下:

修改 workspace\.metadata\.plugins\org.eclipse.wst.server.core\servers.xml文件。

<server hostname="localhost" id="JBoss v5.0 at localhost" name="JBoss v5.0 at localhost" runtime-id="JBoss v5.0" server-type="org.eclipse.jst.server.generic.jboss5" server-type-id="org.eclipse.jst.server.generic.jboss5" start-timeout="1000" stop- timeout="15" timestamp="0">

start-timeout="45" 改为 start-timeout="1000" 或者更长 重启eclipse就可以了。

或者在界面修改

tomcat_time_out2.jpg