我刚刚创建了一个新的java项目,并在eclipse中将其配置为"maven项目".pom.xml文件是自动生成的.此时没有错误.我在自动生成的pom.xml文件中添加了log4j依赖项,它显示了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>Log4JPactice</groupId>
<artifactId>Log4JPactice</artifactId>
<version>0.0.1-SNAPSHOT</version>
<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>
<dependencies>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.15</version>
</dependency>
</dependencies>
</project>
Run Code Online (Sandbox Code Playgroud)
错误:
Multiple annotations found at this line:
- Missing artifact javax.jms:jms:jar:1.1
- ArtifactTransferException: Failure to transfer com.sun.jdmk:jmxtools:jar:1.2.1 from https://maven-repository.dev.java.net/nonav/repository was cached in the local repository, resolution will not be reattempted until the update interval of java.net has elapsed or
updates are forced. Original error: Could not transfer artifact com.sun.jdmk:jmxtools:jar:1.2.1 …
Run Code Online (Sandbox Code Playgroud) 我有一个用户创建屏幕,其中包含各种用户详细信息以及名字和手机号码.我有一个相应的USER表,其中First Name和Mobile号形成一个复合唯一键.此表还定义了其他完整性约束.
在"创建用户"屏幕上输入违反此约束的用户数据时,需要向用户显示"用户友好"错误消息.
当发生这种违规时,我从MySQL数据库获得的异常是:
com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry '1-1' for key `uk_FIRST_NAME__MOBILE_idx`
Run Code Online (Sandbox Code Playgroud)
有两个选项可以显示有意义的消息(例如:"错误:给定手机号码已存在用户名,请更改其中任何一个").
选项1:在此异常的catch块中,解析MySQL异常的消息并查找"uk_FIRST_NAME__MOBILE_idx".如果存在,请显示如上所述的用户友好消息.
选项2:编写DAO级API,将名字和手机号码作为唯一的两个参数,触发数据库查询以查看是否存在与此名字/移动组合匹配的现有记录.如果为true,则向用户显示错误消息; 否则,运行插入查询以将记录用户插入USER表.
我不喜欢选项1,因为它需要我"解析"异常消息,这不是一个干净的解决方案.我也不喜欢选项2,因为它需要我在数据库上运行"两个查询",这比选项1(一个查询解决方案)效率低.
问题:还有其他选择比这两个更好吗?如果不是,哪一个是上述两个中的正确方法?
在JSF2应用程序中,default
当web.xml
文件中没有明确提及时,会话超时是什么?
更新:我正在使用Tomcat,请参考这里关于Tomcat中默认超时的相关帖子.
我想调查我的Web应用程序在Tomcat上的内存占用.除了VisualVM之外,我还想使用VisulGC.
有人可以提供standalone VisualGC
下载链接的链接吗?奇怪的是我找不到它.
我一直在阅读,ArrayList
与其他一些数据结构相比,搜索更快,因为它是基于索引的LinkedList
.我明白ArrayList
内部使用的是Java array
.这是来自Java的代码ArrayList
,它将数据保存在array
.
private transient Object[] elementData;
Run Code Online (Sandbox Code Playgroud)
什么是' 基于索引的数据结构 ',为什么它更快?
此外,什么是数组的内存模型(数组在堆栈/堆组合中的结构),以便我能理解为什么访问数组中的元素更快?