- 博客(253)
- 资源 (1)
- 收藏
- 关注
转载 Java 垃圾回收监视和分析
Java GC监视和分析工具下面是一些可用的工具,每个都有自己的优势和缺点。我们可以通过选择正确的工具并分析,来提升应用程序的性能。这篇教程中,我们选用Java VisualVM。Java VisualVMNaaradGCViewerIBM Pattern Modeling and Analysis Tool for Java Garbage CollectorHPjmeterIBM M
2015-09-28 17:07:00 475
转载 Java 垃圾回收器种类
在Java中,垃圾回收是一个自动的进程可以替代程序员进行内存的分配与回收这些复杂的工作。Java有四种类型的垃圾回收器:串行垃圾回收器(Serial Garbage Collector)并行垃圾回收器(Parallel Garbage Collector)并发标记扫描垃圾回收器(CMS Garbage Collector)G1垃圾回收器(G1 Garbage Collector)每种类型都
2015-09-28 16:53:15 1200
转载 I read that if you specify too large a heap (using -Xmx) then it will slow down the application, is
Yes. No. Maybe. It could slow down the application (as opposed to definitely will slow down the application). Let me explain.First off, you should know by now that the heap should be set to less than
2015-09-28 15:22:33 338
转载 What is the difference between a soft reference and a weak reference in Java?
Weak referencesA weak reference, simply put, is a reference that isn’t strong enough to force an object to remain in memory. Weak references allow you to leverage the garbage collector’s ability to det
2015-09-28 15:12:23 336
转载 A guide to object cloning in java
A clone is an exact copy of the original. In java, it essentially means the ability to create an object with similar state as the original object. The clone() method provides this functionality. In thi
2015-09-28 14:14:11 315
转载 Java Clone, Shallow Copy and Deep Copy
In java, though clone is ‘intended’ to produce a copy of the same object it is not guaranteed. Clone comes with lots of its and buts. So my first advice is to not depend on clones. If you want to provi
2015-09-25 14:46:38 335
转载 java的system.arraycopy()方法
java.lang.System的静态方法arraycopy()可以实现数组的复制,这个方法效率比较高,如果数组有成千上万个元素,那么用这个方法,比用for语句循环快不少。 public static void arraycopy(Object src, int srcPos,
2015-09-25 14:31:46 421
翻译 关于ArrayList的5道面试题
1、ArrayList的大小是如何自动增加的?在ArrayList中增加一个对象的时候,Java会去检查ArrayList,以确保已存在的数组中有足够的容量来存储这个新的对象。如果没有足够的容量,那么就会新建一个长度更长的数组,旧的数组会被使用Arrays.copyOf方法被复制到新的数组中去,现有的数组引用指向了新的数组。//ArrayList Add方法:public boolean add(
2015-09-25 14:20:51 347
转载 hibernate学习笔记3--事务管理
1、只涉及到简单的业务流程(每个业务只涉及一个dao操作) 此时不需要service层,只要dao就够了。 例子: public void insertUser(Users user) { Session session=SessionFactory.openSession(); Transaction ts=session.beginTransac
2015-09-20 22:06:57 296
转载 Difference between a hibernate transaction and a database transaction
Is there a difference between the two? For example within a hibernate transaction we can access the database, run some java code and then access the database again. We can’t do that within a transactio
2015-09-19 01:13:33 293
转载 Spring事务管理(annotation)
5.6 使用@Transactional除了使用XML类型的事务管理,同时Spring也提供了Annotation类型的事务管理。如下所示:// the service class that we want to make transactional@Transactionalpublic class DefaultFooService implements FooService { Foo
2015-09-19 00:47:59 336
转载 spring的annotation-driven配置事务管理器
基于3.0 假定spring 容器中定义了两个事务管理器:transactionManagerX,transactionManagerY,分管两个数据源datasourceX和datasourceY.<tx:annotation-driven transaction-manager="transactionManagerX" /><tx:annotation-driven transaction
2015-09-19 00:39:55 320
转载 解决 spring mvc 3.0 结合 hibernate3.2 使用<tx:annotation-driven>声明式事务无法提交的问题
1、问题复现spring 3.0 + hibernate 3.2 spring mvc使用注解方式;service使用@service注解 事务使用@Transactional事务配置使用 <tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true" /> 在插入或更新数据时
2015-09-18 22:35:38 643
转载 Spring管理 hibernate 事务配置的五种方式
Spring配置文件中关于事务配置总是由三个组成部分,DataSource、TransactionManager和代理机制这三部分,无论是那种配置方法,变化的只是代理机制! 首先创建两个类,一个接口一个实现: package com.dao; public interface UserDao { public void getUser(); }
2015-09-18 22:23:24 322
转载 Spring管理Hibernate事务
1、TransactionProxyFactoryBean<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://
2015-09-18 22:08:02 283
转载 Spring事务配置的五种方式
Spring配置文件中关于事务配置总是由三个组成部分,分别是DataSource、TransactionManager和代理机制这三部分,无论哪种配置方式,一般变化的只是代理机制这部分。 DataSource、TransactionManager这两部分只是会根据数据访问方式有所变化,比如使用Hibernate进行数据访问时,DataSource实际为SessionFactory,Transact
2015-09-18 21:58:18 414
转载 Ehcache 整合Spring 使用页面、对象缓存
EHCache支持内存和磁盘的缓存,支持LRU、LFU和FIFO多种淘汰算法,支持分布式的Cache,可以作为Hibernate的缓存插件。同时它也能提供基于Filter的Cache,该Filter可以缓存响应的内容并采用Gzip压缩提高响应速度。一、准备工作1、 下载jar包Ehcache 对象、数据缓存:http://ehcache.org/downloads/destination?name=
2015-09-16 00:26:54 316
转载 Understanding hibernate first level cache with example
Caching is a facility provided by ORM frameworks which help users to get fast running web application, while help framework itself to reduce number of queries made to database in a single transaction.
2015-09-16 00:12:57 398
转载 Hibernate EhCache configuration tutorial
Caching is facility provided by ORM frameworks which help users to get fast running web application, while help framework itself to reduce number of queries made to database in a single transaction. Hi
2015-09-16 00:03:40 361
转载 Servlet3.0引入的新特性
Servlet3.0规范的新特性主要是为了3个目的: 1.简化开发 2.便于布署 3.支持Web2.0原则为了简化开发流程,Servlet3.0引入了注解(annotation),这使得web布署描述符web.xml不在是必须的选择。Pluggability可插入性当使用任何第三方的框架,如Struts,JSF或Spring,我们都需要在web.xml中添加对应的Servlet的入口。这使得w
2015-09-11 07:19:54 474
转载 Java中getResourceAsStream的用法
代码中读取一些资源文件(txt,gif等等),单独运行的时候,没问题,但是将项目打jar后,尽管资源文件在jar包内,但我们却怎么也访问不到它了。src|---com ---cn ---ChineseUtil.java src|---pinyin.txt ChineseUtil.java package com
2015-09-10 17:24:37 410
转载 ClassLoader.getResourceAsStream() 与 Class.getResourceAsStream()的区别
Class.getResourceAsStream()会指定要加载的资源路径与当前类所在包的路径一致。 例如你写了一个MyTest类在包com.test.mycode下,那么MyTest.class.getResourceAsStream("name") 会在com.test.mycode包下查找相应的资源。 如果这个name是以 ‘/’ 开头的,那么就会从classpath的根路径下开始查找。
2015-09-10 17:07:35 275
转载 [顶]Different ways of loading a file as an InputStream
What’s the difference between:InputStream is = this.getClass().getClassLoader().getResourceAsStream(fileName)andInputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(fileN
2015-09-10 16:51:01 409
转载 ServletContextListener使用详解
在 Servlet API 中有一个 ServletContextListener 接口,它能够监听ServletContext对象的生命周期,实际上就是监听Web应用的生命周期。当Servlet 容器启动或终止Web 应用时,会触发ServletContextEvent事件,该事件由 ServletContextListener来处理。在ServletContextListener接口中定义了处理
2015-09-10 13:35:49 292
转载 How to use Session attributes in Spring-mvc
Could you help me write spring mvc style analog so code in jsp and servlets? session.setAttribute("name","value");and how to add element, that annotate by @ModelAttribute annotation to session and afte
2015-09-09 07:14:22 638
转载 Get Session in Spring AOP
I am no sure if my codes is thread safe,anyone can help?@Aspectpublic class MyAspect { @Autowired private HttpSession session; @Before("...") private void myMethod() { seesion.getId(
2015-09-09 06:23:41 475
转载 Struts2中action获取request、response、session的方式
在struts1.x,request、session是方法自带的,直接调用就可以;在struts2.x中,BaseAction等底层都是封装好的,struts2的request、response、session都被隐藏的了,struts2提供有两种方式。 第一种方式,非IoC(Spring中的控制反转)方式: package com.action; import java.util
2015-09-09 06:19:04 300
转载 Spring中取得session,request等對象
在使用spring時,經常需要在普通類中獲取session,request等對象比如一些AOP攔截器類,在有使用struts2時,因為struts2有一個接口使用org.apache.struts2.ServletActionContext即可很方便的取到session對像. 用法:ServletActionContext.getRequest().getSession(); 但在單獨使用spr
2015-09-08 19:39:42 347
转载 Hibernate – Many-to-Many example (Annotation)
In this tutorial, it will reuse the entire infrastructure of the previous “Hibernate many to many example – XML mapping” tutorial, enhance it to support Hibernare / JPA annotation.Project StructureRevi
2015-09-08 17:26:00 796
转载 Hibernate – Many-to-Many example (XML Mapping)
Many-to-many relationships occur when each record in an entity may have many linked records in another entity and vice-versa.In this tutorial, we show you how to work with many-to-many table relationsh
2015-09-08 17:06:17 309
转载 Hibernate – One-to-Many example (Annotation)
In this tutorial, it will reuse the entire infrastructure of the previous “Hibernate one to many relationship example – XML mapping” tutorial, enhance it to support Hibernate / JPA annotation.Project S
2015-09-08 16:54:03 365
转载 Hibernate – One-to-Many example (XML Mapping)
A one-to-many relationship occurs when one entity is related to many occurrences in another entity.In this tutorial, we show you how to works with one-to-many table relationship in Hibernate, via XML m
2015-09-08 16:50:07 553
转载 Hibernate – One-to-One example (Annotation)
In this tutorial, it will reuse the entire infrastructure of the previous “Hibernate one to one relationship example – XML mapping” tutorial, enhance it to support Hibernate / JPA annotation.Project St
2015-09-08 16:43:56 268
转载 Hibernate – One-to-One example (XML Mapping)
A one-to-one relationships occurs when one entity is related to exactly one occurrence in another entity.In this tutorial, we show you how to work with one-to-one table relationship in Hibernate, via X
2015-09-08 16:28:23 336
转载 Maven 3 + Hibernate 3.6 + Oracle 11g Example (Annotation)
This tutorial will reuse and modify the previous Hibernate3.6 XML mapping tutorial, but replace the Hibernate mapping file (hbm) with Hibernate / JPA Annotation code.Technologies in this article :Mave
2015-09-07 10:31:04 351
转载 Maven 3 + Hibernate 3.6 + Oracle 11g Example (XML Mapping)
In this article, we show you how to integrate Maven3, Hibernate3.6 and Oracle11g together. In the end of this article, you will create a Java project with Maven, and insert a record into Oracle databas
2015-09-07 10:18:35 684
转载 Maven 2 + Hibernate 3.2 + MySQL Example (Annotation)
This tutorial will modify the previous Maven 2 + Hibernate 3.2 + MySQL Example (XML mapping), and replace the Hibernate XML mapping file with Annotation code.Tools & technologies used in this article :
2015-09-07 10:13:20 692
转载 Maven 2 + Hibernate 3.2 + MySQL Example (XML Mapping)
This quick guide show you how to use Maven to generate a simple Java project, and uses Hibernate to insert a record into MySQL database.Tools & technologies used in this article :Maven 2.2.1JDK 1.6.0
2015-09-07 10:09:48 339
转载 How to get web session on Spring AspectJ
I have a question for using Spring AspectJ.I want to create audit log when user do something and get user information from web session to create audit log. Can anyone provide examples of how to do this
2015-09-07 07:32:27 467
转载 How to get session information in Spring MVC 3
I am new to spring MVC and I am trying to get the session information in my controller classRight now I am using HttpSession objHttpSession = request.getSession(true);if I want to get session creati
2015-09-07 07:29:47 508
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人