Spring
共 49 篇文章
Druid学习笔记
官方网站: https://github.com/alibaba/druid/wiki/常见问题 主要功能:sql监控,uri监控,session监控等等 项目中只要引入2个jar包:druid.jar log4j.jar 相关配置: web.xml配置 <!-- druid 数据源,用于采集 web-jdbc 关联监控的数据 --> <!-- 具体参考官网:https://github.com/alibaba/druid/wiki/%E9%85%8D%E7%BD%AE_%E9%85%8D%E7%BD%AEWebStatFilter--> <filter> <filter-name>Drui…
Spring Cache注解+Redis
Spring3.1 Cache注解 依赖jar包: <!-- redis --> <dependency> <groupId>org.springframework.data</groupId> <artifactId>spring-data-redis</artifactId> <version>1.3.4.RELEASE</version> </dependency> <dependency> <groupId>redis.clients</groupId> <artifactId>jedis</artifactId> <version>2.5.2</version> </depende…
2015-01-15 13:36 · Spring
Spring Cache注解+Memcached
Spring3.1 Cache注解 依赖jar包: <!-- simple-spring-memcached --> <dependency> <groupId>com.google.code.simple-spring-memcached</groupId> <artifactId>simple-spring-memcached</artifactId> <version>3.5.0</version> </dependency> <dependency> <groupId>com.google.code.simple-spring-memcached</groupId> <artifac…
2015-01-12 16:11 · Spring · Spring · memcached
Spring4+Hibernate4+Atomikos3.3多数据源事务管理
Spring3+后不再对JTOM提供支持,所以可以改用Atomikos管理多数据源事务。 Spring2.5+Hibernate3+JTOM参考: http://hanqunfeng.iteye.com/blog/1554251 Atomikos官网网站: http://www.atomikos.com/ 一.pom.xml <dependency> <groupId>com.atomikos</groupId> <artifactId>transactions-jdbc</artifactId> <version>3.9.3</version> </dependency> 二.applic…
SpringMVC4零配置--SpringSecurity相关配置【SpringSecurityConfig】
SpringSecurity的配置相对来说有些复杂,如果是完整的bean配置,则需要配置大量的bean,所以xml配置时使用了命名空间来简化配置,同样,spring为我们提供了一个抽象类WebSecurityConfigurerAdapter和一个注解@EnableWebMvcSecurity,达到同样减少bean配置的目的,如下: applicationContext-SpringSecurityConfig.xml <http security="none" pattern="/static/**" /> <http security="none" pattern="/**/*.jsp"…
2014-09-10 18:22 · Spring · SpringSecurity
SpringMVC4零配置--Web上下文配置【MvcConfig】
与SpringSecurity的配置类似,spring同样为我们提供了一个实现类WebMvcConfigurationSupport和一个注解@EnableWebMvc以帮助我们减少bean的声明。 applicationContext-MvcConfig.xml <!-- 启用注解,并定义组件查找规则 ,mvc层只负责扫描@Controller --> <context:component-scan base-package="web.function" use-default-filters="false"> <context:include-filter type="annotatio…
2014-09-10 18:22 · Spring
SpringMVC4零配置--应用上下文配置【AppConfig】
从spring3.0开始,Spring将JavaConfig整合到核心模块,普通的POJO只需要标注@Configuration注解,就可以成为spring配置类,并通过在方法上标注@Bean注解的方式注入bean。 Xml配置和Java类配置对比如下: applicationContext-AppConfig.xml <!-- 激活自动代理功能 参看:web.function.aop.aspect.DemoAspect --> <aop:aspectj-autoproxy proxy-target-class="true" /> <context:component-scan base-p…
2014-09-10 18:21 · Spring
SpringMVC4零配置--web.xml
servlet3.0+规范后,允许servlet,filter,listener不必声明在web.xml中,而是以硬编码的方式存在,实现容器的零配置。 ServletContainerInitializer:启动容器时负责加载相关配置 package javax.servlet; import java.util.Set; public interface ServletContainerInitializer { public void onStartup(Set<Class<?>> c, ServletContext ctx) throws ServletException; } 容器启…
2014-09-10 18:21 · Spring
SpringMVC4零配置
基于Servlet3.0规范和SpringMVC4注解式配置方式,实现零xml配置,弄了个小demo,供交流讨论。 项目说明如下 : 1.db.sql是项目中用到的表,数据库使用的是oracle11g 2.该项目使用mvn进行管理,私服为自搭建nexus,项目只用到一个第三方 jar,就是oracle的驱动; 3.默认项目为零配置启动,如果需要更改启动方式,请作如下操作: <1.使用xml风格测试时,需要先将/src/main/java/web/config下的全部类移动到项目外,并开启web.xml中的相关配置> <2.使用Bean风格测试时,需要保证/src/main/java/web/…
2014-09-05 19:11 · Spring · SpringSecurity
SpringSecurity3.X--LDAP:AD配置
前面介绍过基于本地数据库验证的方式,参考 http://hanqunfeng.iteye.com/blog/1155226 ,这里说一下如何修改为使用AD进行身份验证【只对用户名和密码进行验证,权限依旧存储在本地数据库中】。 将配置文件中的如下部分删除: <!-- 认证管理器,使用自定义的UserDetailsService,并对密码采用md5加密--> <authentication-manager> <authentication-provider user-service-ref="userService"> <password-encoder hash="md5" /> </auth…
2014-07-08 17:08 · Spring · SpringSecurity · Active Directory
Thrift--JSClient
thrift提供了基于jquery--ajax的客户端调用方式,返回json数据。 生成js代码使用如下命令: thrift --gen js Contact.thrift 这样会在gen-js目录下生成两个js文件:Contact_types.js,ContactManager.js,将这两个js文件拷贝到项目中。 同时需要导入thrift.js(thrift-0.9.1\lib\js目录下)和JQuery.js(1.5以上的版本)。 编写一个jsp页面thriftJs.jsp,用于展示客户端的调用方法: <%@ page language="java" contentType="text…
2013-09-26 14:45 · JAVA · Spring · JavaScript · JQuery · thrift
Thrift--Spring集成ThriftServlet
Thrift除了可以通过TCP协议访问,还可以通过HTTP/HTTPS协议访问,在java中,thrift提供了一个servlet:org.apache.thrift.server.TServlet,我们只需继承这个TServlet就可以很方便的将TCP服务转换成HTTP/HTTPS服务,参考 http://hanqunfeng.iteye.com/blog/1936556 ,为其中的ContractManage服务提供servlet接口,如下: 一。基本实现方法 1)服务端 package servlet; import org.apache.thrift.protocol.TCompac…
Thrift转SpringHttpInvoker
关于在spring中集成Thrift请参看: http://hanqunfeng.iteye.com/blog/1936556 javaWeb项目间的通信使用SpringHttpInvoker(关于SpringHttpInvoker请参看: http://hanqunfeng.iteye.com/blog/868210 )也很方便,所以能否在一个server端同时提供Thrift与SpringHttpInvoker两种服务吗? 其实实现起来也比较方便,Thrift和SpringHttpInvoker都是基于接口的实现,所以将Thrift生成的对象的Iface接口移出做为一个独立的接口,然后T…
Spring集成Thrift--Server AND Client
Thrift网上有N多教程,不再赘述,这里搭建的是WEB项目,使用了spring,所以尽量使用了基于配置的方式。 一。server端 本着少些代码,配置优先的原则,在server端引入代理类,如下: ThriftServerProxy:使用了反射 public class ThriftServerProxy { private static Logger logger = Logger.getLogger(ThriftServerStartListener.class); private int port;// 端口 private String serviceInterface;// 实现…
C3P0配置实战
C3P0: 一个开源的JDBC连接池,它实现了数据源和JNDI绑定,支持JDBC3规范和JDBC2的标准扩展。目前使用它的开源项目有Hibernate,Spring等。 默认情况下(即没有配置连接池的情况下),Hibernate会采用内建的连接池。但这个连接池性能不佳,因此官方也只是建议仅在开发环境下使用。Hibernate支持第三方的连接池,官方推荐的连接池是C3P0,Proxool。 这里说一下为什么一定要使用C3P0吧: 1)hibernate官网推荐 2) 解决数据库重启后tomcat在不需要重启的情况下即可重新获得数据连接的问题。 下载: http://www.mchange.co…
2012-09-04 18:34 · JAVA · Spring · Hibernate · C3P0 · Spring · Hibernate · c3p0
spring+jotm 多数据源事务管理(三)JNDI+Tomcat
spring+jotm 多数据源事务管理系列 spring+jotm 多数据源事务管理(一)jdbc spring+jotm 多数据源事务管理(二)hibernate spring+jotm 多数据源事务管理(三)JNDI+Tomcat 首先需要将jotm相关jar包加入到tomcat中,如下: o jotm.jar o jotm_jrmp_stubs.jar o ow_carol.jar o jta.jar o jta-spec1_0_1.jar o jts1_0.jar o objectweb-datasource.jar o xapool.jar o howl.jar o common…
spring+jotm 多数据源事务管理(二)hibernate
spring+jotm 多数据源事务管理系列 spring+jotm 多数据源事务管理(一)jdbc spring+jotm 多数据源事务管理(二)hibernate spring+jotm 多数据源事务管理(三)JNDI+Tomcat 使用hibernate关联jotm也很方便,先看一个没有使用jotm的例子: <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema…
spring+jotm 多数据源事务管理(一)jdbc
spring+jotm 多数据源事务管理系列 spring+jotm 多数据源事务管理(一)jdbc spring+jotm 多数据源事务管理(二)hibernate spring+jotm 多数据源事务管理(三)JNDI+Tomcat JOTM (Java Open Transaction Manager)是由ObjectWeb协会开发的功能完整的且资源开放的独立的事务管理器。 它提供了 JAVA 应用程序的事务支持,而且与 JTA( JAVA 事务 API)兼容。您可以在 JOTM home page 了解到更多的详细信息。 本文介绍如何在spring配置文件中加入jotm来实现多数据源…
SpringSecurity3.X--Cas client 配置之配置session-management遇到的问题(2)
关于“SpringSecurity3.X--Cas client 配置之配置session-management遇到的问题(1)”请参看http://hanqunfeng.iteye.com/blog/1217703 接着说,按照前文配置的方式,只能迫使用户第一次访问时跳转到指定的“expiredUrl”,但此时,如果你再次访问系统,你会发现,系统会自动重新登录,并跳转到“authenticationSuccessHandler”中指定的“defaultTargetUrl”,相当于重新登录了。 这是为什么呢? 其实,ConcurrentSessionFilter验证用户过期时,只是将当前的s…
2011-10-27 14:19 · Spring · SpringSecurity · Spring · CAS · springsecurity
SpringSecurity3.X--Cas client 配置之配置session-management遇到的问题
关于“SpringSecurity3.X--Cas client 配置”可以参看 SpringSecurity3.X--Cas client 配置 直接说问题吧,就是希望同一时间相同的用户只能有一个访问系统,我理所当然的想到了session-management,在使用SpringSecurity2.x时,直接配置如下即可: <sec:http entry-point-ref="casProcessingFilterEntryPoint" access-denied-page="/access/denied.do" access-decision-manager-ref="accessDec…
2011-10-26 18:56 · Spring · SpringSecurity · Spring · CAS · springsecurity