Java如何在Spring AOP中返回Map 10C

Java如何在Spring AOP中返回Map

各路Java业界大神,请帮小弟一把。
在spring mvc的控制器中,需要频繁返回Map来反应前端网页是否修改成功。

所以我就想做一个AOP控制所有的void delete*()等方法实现自动加上Map类型返回。

以下是未修改代码:

@RequestMapping("delete")

@ResponseBody

public Map delete(Integer id){

    Map<String,String> tipMessages=new HashMap<String,String>();

    try{

        xxxService.delete(Integer id);

        tipMessages.put("status", "Y");

        tipMessages.put("info","删除成功");

    }catch(Exception e){

        tipMessages.put("status", "N");

        tipMessages.put("info", "删除失败");

    }

    return tipMessages;


理想状态:

@Around("pointCut()")  

    public Object doAround(ProceedingJoinPoint pjp) throws Throwable {  

      try{ 

                Object o = pjp.proceed();  

                //正常处理

                tipMessages.put("status", "Y");

                tipMessages.put("info","删除成功");

            }catch(Exception e){

                tipMessages.put("status", "N");

                tipMessages.put("info", "删除失败");

      }

    return o;  

}  

    Class xxxService{

        public Map<String,String> delete(){

            xxxRepository.delete();

        }

    }

    不知从何下手,望大神门指点迷津。

3个回答

@ResponseBody

加了这个标记会返回一个json数据,其实在这个地方,你的中文描述tipMessages.put("info","删除成功");和删除失败,完全可以放在前台用js处理,后台只
返回Y或者N即可。可以按f12,看下Network,看你的请求返回的是什么,用JS进行处理。

Angel757774164
小枫C 我就要统一处理这些,如果每个网页都加上,还要AOP干嘛。。。
大约 4 年之前 回复

这块我也不太会,不过感觉你那个方法得改成:
@Around("pointCut()")

public Object doAround(ProceedingJoinPoint pjp) throws Throwable {  
        Map<String,String> tipMessages=new HashMap<String,String>();
  try{ 

            tipMessages = (Map<String,String>) pjp.proceed();  

            //正常处理

            tipMessages.put("status", "Y");

            tipMessages.put("info","删除成功");

        }catch(Exception e){

            tipMessages.put("status", "N");

            tipMessages.put("info", "删除失败");

  }

return tipMessages;  

}

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
一个用spring aop拦截struts action的问题
最近我需要在不改变原有的代码的前提下,记录到达struts action的HttpServletRequest和HttpServletResponse,我的第一想法就是用spring aop来做拦截。但是,这样做使得原来struts action无法获得struts上下文的内容信息,为了说明问题,我写了一个小原型,代码如下: [color=red]类SimpleAction,这个类是用来封装获得HttpServletRequest和HttpServletResponse的方法的,跟本主题关系不大,可以跳过。[/color] package action; import java.util.Map; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.struts2.interceptor.ServletRequestAware; import org.apache.struts2.interceptor.ServletResponseAware; import org.apache.struts2.interceptor.SessionAware; import com.opensymphony.xwork2.ActionSupport; public class SimpleAction extends ActionSupport implements ServletRequestAware, ServletResponseAware ,SessionAware{ protected HttpServletRequest servletRequest; protected HttpServletResponse servletResponse; protected Map session; public Map getSession() { return session; } public void setSession(Map session) { this.session = session; } public void setServletRequest(HttpServletRequest request) { this.servletRequest = request; } public HttpServletRequest getServletRequest() { return this.servletRequest; } public void setServletResponse(HttpServletResponse response) { this.servletResponse = response; } public HttpServletResponse getServletResponse() { return this.servletResponse; } } 类LoginAction,这个类的execute就是struts处理action调用的方法,但是奇怪的是,在这个方法中,本应得到jsp传来的值得username和password为空(把spring aop相关配置注释掉之后,username和password能正常传值)。loginService.validate()用作判断username和password是否符合,不符合以抛出异常的方式来告知调用者。在加上spring aop后,由于[color=red]username和password为空[/color],所以就一直返回结果"usernameInvalid"。 package action; import org.apache.struts2.interceptor.ServletRequestAware; import org.apache.struts2.interceptor.ServletResponseAware; import org.apache.struts2.interceptor.SessionAware; import service.LoginService; import exception.*; public class LoginAction extends SimpleAction { private String username; private String password; private LoginService loginService; public LoginService getLoginService() { return loginService; } public void setLoginService(LoginService loginService) { this.loginService = loginService; } public String getUsername() { return username; } public void setUsername(String username) { this.username = username; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } @Override public void validate() { } @Override public String execute() { try{ this.getServletRequest().setAttribute("username", username); this.getServletRequest().setAttribute("password", password); System.out.println("username"+username); System.out.println("username"+getUsername()); boolean result = loginService.validate(username, password); }catch(UsernameException ue) { return "usernameInvalid"; }catch(PasswordException pe) { return "passwordInvalid"; }catch(Exception e) { e.printStackTrace(); return INPUT; } return SUCCESS; } } 下面是advice类,用来处理调用方法后的日志记录工作 package advice; import java.io.*; import java.lang.reflect.Method; import org.apache.log4j.Logger; import org.apache.log4j.PropertyConfigurator; import org.springframework.aop.AfterReturningAdvice; import org.springframework.aop.MethodBeforeAdvice; import org.springframework.aop.ThrowsAdvice; public class LogActionAdvice implements AfterReturningAdvice { public void afterReturning(Object arg0, Method arg1, Object[] arg2, Object target) { // TODO Auto-generated method stub try { PropertyConfigurator.configure("after.properties"); Logger logger = Logger.getLogger(target.getClass()); logger.debug("..."); }catch(Exception e) { e.printStackTrace(); } } } 下面是login页面,这个页面的username空间对应action的username属性,所以应该不是struts没有配alias的问题,这里是login.jsp代码 <%@ page language="java" pageEncoding="GB2312"%> <%@ taglib prefix="s" uri="/struts-tags"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//CN"> <html> <head> <title>login2</title> </head> <body> <s:form name="login" action="login" method="post" > <s:textfield name="username" label="帐号"></s:textfield> <s:password name="password" label="密码"></s:password> <s:submit></s:submit> </s:form> </body> </html> 下面是配置文件,首先是struts的配置文件struts.xml: <?xml version="1.0" encoding="GB2312" ?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"> <struts> <package name="struts2" extends="struts-default"> <action name="login" class="LoginAction"> <result name="success">/index.jsp</result> <result name="input">/login.jsp</result> <result name="usernameInvalid">/usernameInvalid.jsp</result> <result name="passwordInvalid">/passwordInvalid.jsp</result> </action> </package> </struts> 再来是spring的配置文件applicationContext.xml,红色部分是advice的配置,具体是匹配所有*Action的execute方法。 <?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:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:ehcache="http://www.springmodules.org/schema/ehcache" xmlns:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd http://www.springmodules.org/schema/ehcache http://www.springmodules.org/schema/cache/springmodules-ehcache.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd" default-lazy-init="true" default-autowire="byName"> [color=red] <aop:config> <aop:advisor id="methodAroundAdviceAdvisor" advice-ref="logActionAdvice" pointcut="execution(* *..*Action.execute(..))" /> </aop:config> <bean id="logActionAdvice" class="advice.LogActionAdvice" />[/color] <bean name="loginService" class="service.LoginService" /> <bean name="LoginAction" class="action.LoginAction"> <property name="loginService"> <ref bean="loginService"/> </property> </bean> </beans> 最后是web.xml的源码: <?xml version="1.0" encoding="UTF-8"?> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <!-- 加载struts2核心 --> <filter> <filter-name>struts2</filter-name> <filter-class> org.apache.struts2.dispatcher.FilterDispatcher </filter-class> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <!-- 指明spring配置文件在何处 --> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:applicationContext.xml</param-value> </context-param> <!-- 加载spring配置文件applicationContext.xml --> <listener> <listener-class> org.springframework.web.context.ContextLoaderListener </listener-class> </listener> </web-app> 在这个原型中出现的问题是,在LoginAction中,username和password为空,但是,[color=red]如果把它们set到 HttpServletRequest中,在页面usernameInvalid.jsp中却能够得到username和password的值。[/color]事先我查过一些资料,说用spring aop自动生成的代理无法获得struts上下文传递的变量值,但是我想不通为何把它们set到HttpServletRequest后却能够在前端页面显示出正确的值。 谢谢您的阅读和帮助!
求大神帮忙 spring aop 方式事务不回滚怎么搞?
spring 版本 4.1.7 代码如下: 表: CREATE TABLE `users` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `nick_name` varchar(100) DEFAULT NULL, `password` varchar(100) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8; INSERT INTO `users` VALUES ('1', 'Jennifer', 'Alice'); INSERT INTO `users` VALUES ('2', '爱', '克斯莱'); java 文件: 1) package com.maxwell.spring.jdbc.tx; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.maxwell.spring.jdbc.vo.User; @Service public class UserAopService { @Autowired private UserDao dao; public UserAopService() {} /** * 此处的@Transactional注解把这个方法中的所有数据库操作当作事务进行处理 */ public void testTransactionManager() { String nn = dao.addUser(new User().setNickName("Jensen").setPassword("jensen")); int i = dao.getIdByNickName(nn); System.out.println(i); dao.setNickNameById(i, "Nimei"); } } 2) package com.maxwell.spring.jdbc.tx; import java.util.HashMap; import java.util.List; import java.util.Map; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.jdbc.core.BeanPropertyRowMapper; import org.springframework.jdbc.core.RowMapper; import org.springframework.jdbc.core.namedparam.BeanPropertySqlParameterSource; import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate; import org.springframework.jdbc.core.namedparam.SqlParameterSource; import org.springframework.stereotype.Repository; import com.maxwell.spring.jdbc.vo.User; /** * 用于测试事务 * @author Techwork * */ @Repository public class UserDao { @Autowired @Qualifier("npJdbcTpl") private NamedParameterJdbcTemplate jdbcTpl; public String addUser(User user) { String sql = "INSERT INTO users (nick_name, password) VALUES (:nickName, :password)"; SqlParameterSource paramSource = new BeanPropertySqlParameterSource(user); jdbcTpl.update(sql, paramSource); return user.getNickName(); } public int getIdByNickName(String nickName) { String sql = "select id, nick_name, password from users where nick_name = :xxx"; Map<String, Object> paramMap = new HashMap<>(); paramMap.put("xxx", nickName); RowMapper<User> rowMapper = new BeanPropertyRowMapper<>(User.class); List<User> users = jdbcTpl.query(sql, paramMap, rowMapper); if(users == null || users.size() < 1) { throw new RuntimeException("无此用户:" + nickName); } return users.get(0).getId(); } public void setNickNameById(int id, String nickName) { if(nickName.length() < 10) throw new RuntimeException("性别错误"); String sql = "update users set nick_name = :n where id = :i"; Map<String, Object> paramMap = new HashMap<>(); paramMap.put("n", nickName); paramMap.put("i", id); jdbcTpl.update(sql, paramMap); } } 3) package com.maxwell.spring.jdbc.tx; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Isolation; import org.springframework.transaction.annotation.Transactional; import com.maxwell.spring.jdbc.vo.User; @Service public class UserService { @Autowired private UserDao dao; public UserService() {} /** * 此处的@Transactional注解把这个方法中的所有数据库操作当作事务进行处理 */ @Transactional public void testTransactionManager() { String nn = dao.addUser(new User().setNickName("Jensen").setPassword("jensen")); int i = dao.getIdByNickName(nn); System.out.println(i); dao.setNickNameById(i, "Nimei"); } /** * propagation: 指定事务的传播行为 * isolation: 指定事务的隔离级别 * noRollbackFor: 指定对哪些异常不回滚。通常取默认值。 * rollbackFor: 指定对哪些异常回滚。通常取默认值。 * readOnly: 只读事务。如果事务只读取数据,而不写数据的话,设置为true,有助于数据库引擎优化事务。 * timeout: 指定强制回滚事务(就算可能成功)之前,事务可以存在的时间,以防止事务占用数据库连接时间过长。 */ @Transactional(isolation = Isolation.READ_COMMITTED, noRollbackFor = { Exception.class }, rollbackFor = { RuntimeException.class }, readOnly = true, timeout = 3) public void testTransactionManager2() { String nn = dao.addUser(new User().setNickName("Jensen").setPassword("jensen")); int i = dao.getIdByNickName(nn); dao.setNickNameById(i, "哈哈"); } } 4) package com.maxwell.spring.jdbc; import org.junit.Test; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import com.maxwell.spring.jdbc.tx.UserAopService; /** * 测试AOP事务 * * @author Angrynut * */ public class AOPTransactionTest { private ApplicationContext ctx = null; private UserAopService service = null; { ctx = new ClassPathXmlApplicationContext("aoptx.xml"); service = ctx.getBean("userAopService", UserAopService.class); } /** * 1.测试AOP事务。 */ @Test public void testTransactionManager() { service.testTransactionManager(); } } spring 配置文件: <?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:util="http://www.springframework.org/schema/util" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.1.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.1.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.1.xsd"> <context:component-scan base-package="com.maxwell.spring.jdbc"/> <!-- 数据源配置文件 --> <util:properties id="db" location="classpath:db.properties"/> <!-- 配置C3p0数据源 --> <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"> <property name="user" value="#{db['jdbc.user']}"/> <property name="password" value="#{db['jdbc.password']}"/> <property name="driverClass" value="#{db['jdbc.driverClass']}"/> <property name="jdbcUrl" value="#{db['jdbc.jdbcUrl']}"/> <property name="initialPoolSize" value="#{db['jdbc.initPoolSize']}"/> <property name="maxPoolSize" value="#{db['jdbc.maxPoolSize']}"/> </bean> <bean id="npJdbcTpl" class="org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate"> <constructor-arg ref="dataSource"/> </bean> <!-- 配置事务管理器 --> <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="dataSource"/> </bean> <tx:advice id="txAdvice" transaction-manager="transactionManager"> <tx:attributes> <tx:method name="*" propagation="REQUIRED"/> </tx:attributes> </tx:advice> <aop:config> <aop:pointcut expression="execution(* com.maxwell.spring.jdbc.tx.UserService.*(..))" id="pc"/> <aop:advisor advice-ref="txAdvice" pointcut-ref="pc"/> </aop:config> </beans>
如何用spirng aop aspectj自定义注解 切 servlet中的doPost
想实现一个功能,就是记录用户的操作日志 想用aop加自定义注解实现 Controller ``` @SupplierLog(event = "获取订单列表") @RequestMapping("/getOrderList.do") public Map getOrderList(HttpSession session,@RequestBody Map param) { } ``` AOP ``` @Pointcut("@annotation(com.hanzhisoft.tender.annotation.SupplierLog)") public void logPointCut(){ } @Before("logPointCut() && @annotation(supplierLog)") public void before(SupplierLog supplierLog) throws Throwable { SupplierUser user = (SupplierUser) session.getAttribute("currUser"); Map<Object, Object> map = new HashMap<>(); map.put("log_pk", UUIDUtil.getUUID().toUpperCase()); map.put("userid", user.getUserid()); map.put("cusname", user.getSupplireName()); map.put("ip_address", request.getRemoteAddr()); map.put("pk_eppuser", user.getPk_eppuser()); map.put("event", supplierLog.event()); System.out.println(map); System.out.println("切面执行完毕"); } ``` 在Controller的方法中加已经可以实现了。 但是由于项目比较旧,有很多功能是用servlet实现的,此时想在doPost中添加自定义注解,发现并不生效,就算把Servlet交给Spring管理也不能实现。 ``` @SupplierLog(event = "竞价中心") public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/xml;charset=utf-8"); request.setCharacterEncoding("utf-8"); ```
怎么包裹RestController的返回值?
例如原始返回值是 ”This is response“, 返回 ``` { "status":1, "content":"This is response” } ``` 异常时返回 ``` { "status":0, "content":"exception message” } ``` 使用spring aop没有实现预期的结果 ``` @Component @Aspect @EnableAspectJAutoProxy public class ResponseWrapping { @Pointcut("within(@org.springframework.web.bind.annotation.RestController *)") public void restPointcut() { } @Pointcut("execution(* *(..))") public void anyMethodPointcut() { } @AfterReturning(value = "restPointcut() && anyMethodPointcut()", returning = "response") public Object wrapResponse(Object response) { Map<String, Object> result = new HashMap<>(); result.put("status", 1); result.put("data", response); return result; } @AfterThrowing(value = "restPointcut() && anyMethodPointcut()", throwing = "exception") public Object wrapException(RuntimeException exception) { Map<String, Object> result = new HashMap<>(); result.put("status", 0); result.put("msg", exception.getMessage()); return result; } } ``` 测试用controller ``` @RestController @RequestMapping("/admin") public class TestController { @RequestMapping(value = "/test", method = RequestMethod.GET) public Object test(@RequestParam("test") int test) { if (test == 0) throw new RuntimeException("This is an exception test response"); else return "This is normal test response"; } } ```
Error querying database. Cause: java.lang.NullPointerException
###错误日志 org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: Error querying database. Cause: java.lang.NullPointerException Cause: java.lang.NullPointerException at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:79) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:447) at com.sun.proxy.$Proxy82.selectOne(Unknown Source) at org.mybatis.spring.SqlSessionTemplate.selectOne(SqlSessionTemplate.java:167) at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:75) at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:53) at com.sun.proxy.$Proxy180.shareRewardList(Unknown Source) at com.cn.ym.live.hottalk.service.common.impl.UserInfoServiceImpl.shareRewardList(UserInfoServiceImpl.java:82) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:333) at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213) at com.sun.proxy.$Proxy178.shareRewardList(Unknown Source) at com.cn.ym.live.hottalk.controller.UserInfoController.shareRewardList(UserInfoController.java:119) at com.cn.ym.live.hottalk.controller.UserInfoController$$FastClassBySpringCGLIB$$728252b4.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:738) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) at org.springframework.validation.beanvalidation.MethodValidationInterceptor.invoke(MethodValidationInterceptor.java:139) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:85) at com.cn.ym.live.hottalk.aop.WebControllerAop.doAround(WebControllerAop.java:46) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:629) at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:618) at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:70) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:673) at com.cn.ym.live.hottalk.controller.UserInfoController$$EnhancerBySpringCGLIB$$e47575b0.shareRewardList(<generated>) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:133) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:97) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:963) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970) at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872) at javax.servlet.http.HttpServlet.service(HttpServlet.java:661) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846) at javax.servlet.http.HttpServlet.service(HttpServlet.java:742) at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129) at com.cn.ym.live.hottalk.aop.MyFilter.doFilter(MyFilter.java:62) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:105) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:81) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84) at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62) at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131) at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46) at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64) at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60) at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77) at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.servlet.handlers.SessionRestoringHandler.handleRequest(SessionRestoringHandler.java:119) at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:292) at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:81) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:138) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:135) at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48) at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43) at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:272) at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81) at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:104) at io.undertow.server.Connectors.executeRootHandler(Connectors.java:211) at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:809) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Caused by: org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. Cause: java.lang.NullPointerException ### Cause: java.lang.NullPointerException at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30) at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:150) at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:141) at org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne(DefaultSqlSession.java:77) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:434) ... 104 common frames omitted Caused by: java.lang.NullPointerException: null at com.cn.ym.live.hottalk.config.db.MyAbstractRoutingDataSource.determineCurrentLookupKey(MyAbstractRoutingDataSource.java:24) at org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource.determineTargetDataSource(AbstractRoutingDataSource.java:196) at org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource.getConnection(AbstractRoutingDataSource.java:164) at com.github.pagehelper.PageHelper.getUrl(PageHelper.java:281) at com.github.pagehelper.PageHelper.getSqlUtil(PageHelper.java:305) at com.github.pagehelper.PageHelper.initSqlUtil(PageHelper.java:263) at com.github.pagehelper.PageHelper.intercept(PageHelper.java:250) at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:61) at com.sun.proxy.$Proxy168.query(Unknown Source) at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:148) ... 111 common frames omitted 2018-12-20 17:20:15.347 WARN 9616 --- [ XNIO-3 task-1] .m.m.a.ExceptionHandlerExceptionResolver : Resolved exception caused by Handler execution: org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: Error querying database. Cause: java.lang.NullPointerException Cause: java.lang.NullPointerException ###mapper.xml <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN" "http://ibatis.apache.org/dtd/ibatis-3-mapper.dtd"> <mapper namespace="com.cn.ym.live.hottalk.dao.UserInviteLogDAO"> <!-- --> <select id="shareRewardList" resultType="ShareReward"> SELECT COUNT(invite_id) as number, SUM(coin) as money FROM hot_user_invite_log </select> ###dao层 public interface UserInviteLogDAO { /** * 日志增加用户邀请奖励 奖励金额 * * @param inviteLog */ public void addCoin(InviteLog inviteLog); /** * 获取邀请码 用户信息 * * @param map uid * @return */ public UserInfo userInviteLogDao(Map<String, Object> map1); /** * 用户获取邀请信息 * * @param uid * @param start_time * @param end_time * @return */ public ShareReward shareRewardList(); ###service @Autowired private UserInviteLogDAO userInviteLogDao; @Autowired private PayOrderDAO payOrderDAO; private static final Logger logger = LoggerFactory.getLogger(UserInfoService.class); /** * 用户获取邀请信息 * @param uid * @param start_time * @param end_time * @return */ public ShareReward shareRewardList(String uid, Long start_time, Long end_time) { Map<String , Object> map =new HashMap<>(); map.put("uid", uid); map.put("start_time", start_time); map.put("end_time", end_time); ShareReward shareReward = userInviteLogDao.shareRewardList(); return shareReward; }
spring4.0+hessian4.0+tomcat7启动报createIdentityMapIfPossible(I)Ljava/util/Map
<div class="iteye-blog-content-contain" style="font-size: 14px;"> <p>如题,报了如下错误</p> <div class="quote_title">写道</div> <div class="quote_div">java.lang.NoSuchMethodError: org.springframework.core.CollectionFactory.createIdentityMapIfPossible(I)Ljava/util/Map;<br> at org.springframework.aop.framework.AdvisedSupport.initDefaultAdvisorChainFactory(AdvisedSupport.java:120)<br> at org.springframework.aop.framework.AdvisedSupport.&lt;init&gt;(AdvisedSupport.java:103)<br> at org.springframework.aop.framework.ProxyCreatorSupport.&lt;init&gt;(ProxyCreatorSupport.java:47)<br> at org.springframework.aop.framework.ProxyFactory.&lt;init&gt;(ProxyFactory.java:40)<br> at org.springframework.remoting.support.RemoteExporter.getProxyForService(RemoteExporter.java:156)<br> at org.springframework.remoting.caucho.HessianExporter.prepare(HessianExporter.java:126)<br> at org.springframework.remoting.caucho.HessianExporter.afterPropertiesSet(HessianExporter.java:117)<br> at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1612)<br> at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1549)<br> at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)<br> at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)<br> at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302)<br> at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)<br> at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298)<br> at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)<br> at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:703)<br> at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760)<br> at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)<br> at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:658)<br> at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:624)<br> at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:672)<br> at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:543)<br> at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:484)<br> at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136)<br> at javax.servlet.GenericServlet.init(GenericServlet.java:160)<br> at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1280)<br> at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1193)<br> at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1088)<br> at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5176)<br> at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5460)<br> at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)<br> at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)<br> at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)<br> at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)<br> at java.util.concurrent.FutureTask.run(FutureTask.java:166)<br> at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)<br> at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)<br> at java.lang.Thread.run(Thread.java:722)</div> <p> 网上搜了下,有说是缺少包。我依赖的包如下:</p> <p>junit-3.8.1.jar</p> <p>hessian-4.0.38.jar</p> <p>spring-webmvc-4.0.6.RELEASE.jar</p> <p>spring-beans-4.0.6.RELEASE.jar</p> <p>spring-context-4.0.6.RELEASE.jar</p> <p>spring-core-4.0.6.RELEASE.jar</p> <p>spring-expression-4.0.6.RELEASE.jar</p> <p>spring-web-4.0.6.RELEASE.jar</p> <p>spring-remoting-2.0.8.jar</p> <p>aopalliance-1.0.jar</p> <p>commons-logging-1.1.jar</p> <p>log4j-1.2.12.jar</p> <p>logkit-1.0.1.jar</p> <p>avalon-framework-4.1.3.jar</p> <p>spring-aop-2.0.8.jar</p> <p>servlet-api-2.3.jar</p> <p>spring-jms-4.0.6.RELEASE.jar</p> <p>spring-tx-4.0.6.RELEASE.jar</p> <p>spring-context-support-4.1.0.RELEASE.jar</p> <p> </p> <p>不知道缺少哪个包,求帮助</p> </div>
springboot项目下,提示shiro与aop冲突
我用的是springboot微框架。权限管控用的shiro,现在要使用aop,总是报以下错误: Error creating bean with name 'shiroFilterFactoryBean' defined in class path resource [com/zcy/salesPlatform/shiro/ShiroConfig.class]: BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration': Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: Pointcut is not well-formed: expecting 'identifier' at character position 0 * com.zcy.salesPlatform.action.sell.order.*.*(..) 我的aop类: ``` package com.zcy.salesPlatform.aop; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Before; import org.aspectj.lang.annotation.Pointcut; import org.springframework.stereotype.Component; @Aspect @Component public class LoggerAop { @Pointcut("* com.zcy.salesPlatform.action.sell.order.*.*(..)") public void loggerAspect(){} @Before("loggerAspect()") public void before() { System.out.println("切面before执行了"); } /*@After("loggerAspect()") public void after() { System.out.println("切面after执行了"); } @AfterReturning("loggerAspect()") public void afterReturning() { System.out.println("切面afterReturning执行了"); } @AfterThrowing("loggerAspect()") public void afterThrowing() { System.out.println("切面afterThrowing执行了"); }*/ /*@Around("loggerAspect()") public Object around(ProceedingJoinPoint thisJoinPoint){ Object obj = null; System.err.println ("切面around before执行了"); try { thisJoinPoint.proceed(); } catch (Throwable e) { e.printStackTrace (); } System.err.println ("切面around after执行了"); return obj; }*/ } ``` 我的shiro。config类: ``` package com.zcy.salesPlatform.shiro; import java.util.LinkedHashMap; import java.util.Map; import org.apache.shiro.spring.LifecycleBeanPostProcessor; import org.apache.shiro.spring.web.ShiroFilterFactoryBean; import org.apache.shiro.web.mgt.DefaultWebSecurityManager; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; /** * spring boot 集成shiro的配置 http://blog.csdn.net/catoop/article/details/50520958 * * @author luanhaibin */ @Configuration public class ShiroConfig { private static Map<String, String> filterChainDefinitionMap = new LinkedHashMap<String, String>(); @Bean(name = "shiroFilterFactoryBean") public ShiroFilterFactoryBean shiroFilterFactoryBean() { ShiroFilterFactoryBean shiroFilterFactoryBean = new ShiroFilterFactoryBean(); shiroFilterFactoryBean.setSecurityManager(securityManager()); shiroFilterFactoryBean.setLoginUrl("/user/login"); shiroFilterFactoryBean.setSuccessUrl("/menu/menuIndex"); // filterChainDefinitionMap.put("/menu/**", "authc"); // filterChainDefinitionMap.put("/personcenter/**", "authc"); filterChainDefinitionMap.put("/**", "anon"); // shiroFilterFactoryBean.setFilterChainDefinitionMap(filterChainDefinitionMap); return shiroFilterFactoryBean; } @Bean(name = "securityManager") public DefaultWebSecurityManager securityManager() { DefaultWebSecurityManager defaultWebSecurityManager = new DefaultWebSecurityManager(); defaultWebSecurityManager.setRealm(shiroRealm()); return defaultWebSecurityManager; } @Bean(name = "shiroRealm") public ShiroRealm shiroRealm() { return new ShiroRealm(); } @Bean(name = "lifecycleBeanPostProcessor") public LifecycleBeanPostProcessor lifecycleBeanPostProcessor() { // AbstractNativeSessionManager a=new AbstractNativeSessionManager(); return new LifecycleBeanPostProcessor(); } } ``` 请教各位老师各位大神,怎么破?
springboot2.1.4 + jpa + hibernate 使用aop注解形式实现多数据源管理 可能懒加载出现问题求大神解答
最近项目中使用springboot2.1.4 + jpa + hibernate 使用aop注解形式实现多数据源管理,用的就是网上大多数人使用的一套代码,但是我在项目中使用后发现如果配置 spring配置文件 application.yml 中open-in-view: false 跨数据源查询正常,但是保存或者修改失败原因是事务没有提交,一旦把open-in-view改成true则不能跨数据源查询,修改保存正常事务正常提交求解,具体代码如下实现 1. application.yml ``` spring: ## 数据库配置 #datasource: #driver-class-name: com.mysql.jdbc.Driver #url: jdbc:mysql://192.168.101.125:3306/cdv?useSSL=false&characterEncoding=utf-8 #username: root #password: 123456 #url: jdbc:mysql://127.0.0.1:3306/boot-jpa-back-sys2?useSSL=false&characterEncoding=utf-8 #username: root #password: datasource: test1: driver-class-name: com.mysql.jdbc.Driver jdbc-url: jdbc:mysql://192.168.101.125:3306/cdv?useSSL=false&characterEncoding=utf-8 username: root password: 123456 type: com.alibaba.druid.pool.DruidDataSource test2: driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver jdbc-url: jdbc:sqlserver://192.168.101.125:1433;database=Test; username: sa password: Zqvideo123 type: com.alibaba.druid.pool.DruidDataSource ## jpa配置 jpa: show-sql: true hibernate: #ddl-auto: update properties: hibernate.dialect: com.common.mysql.MySQLDialectUTF8 hibernate.format_sql: false open-in-view: false ``` DataSourceAsepct ``` package com.common.db; import java.lang.reflect.Method; import org.aspectj.lang.JoinPoint; import org.aspectj.lang.annotation.AfterThrowing; import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Before; import org.aspectj.lang.annotation.Pointcut; import org.aspectj.lang.reflect.MethodSignature; import org.springframework.core.annotation.Order; import org.springframework.stereotype.Component; @Aspect @Component @Order(0) public class DataSourceAsepct { //加载数据源 @Pointcut("@annotation(com.common.db.DataSourceSet)") // @AfterThrowing(pointcut="@annotation(com.common.db.DataSource)", throwing= "error") public void pointCut(){ } @Before("pointCut()") public void before(JoinPoint joinPoint) { Object target = joinPoint.getTarget(); MethodSignature signature = (MethodSignature) joinPoint.getSignature(); DataSourceEnum dataSource = DataSourceEnum.DEFAULT; try { Method method = target.getClass().getMethod(signature.getName(), signature.getParameterTypes()); if (method.isAnnotationPresent(DataSourceSet.class)) { DataSourceSet annotation = method.getAnnotation(DataSourceSet.class); dataSource = annotation.value(); } } catch (NoSuchMethodException e) { e.printStackTrace(); } //实现aop切换数据源 System.out.println("aop切换数据源:" + dataSource.getName()); DataSourceHolder.setDataSource(dataSource); } // @After("pointCut()") @AfterThrowing(pointcut="@annotation(com.common.db.DataSourceSet)", throwing= "error") public void after() { DataSourceHolder.clearDataSource(); String v = DataSourceHolder.getDataSource(); System.out.println(v); } } ``` DataSourceConfig ``` package com.common.db; import java.util.HashMap; import java.util.Map; import javax.sql.DataSource; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.jdbc.DataSourceBuilder; import org.springframework.boot.jta.atomikos.AtomikosDataSourceBean; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Primary; import org.springframework.jdbc.datasource.DataSourceTransactionManager; import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.jta.JtaTransactionManager; @Configuration public class DataSourceConfig { //连接数据库db1 @Bean("test1") @ConfigurationProperties("spring.datasource.test1") public DataSource test1() { return DataSourceBuilder.create().build(); } //连接数据库db2 @Bean("test2") @ConfigurationProperties("spring.datasource.test2") public DataSource test2() { return DataSourceBuilder.create().build(); } @Bean("dynamicDataSource") @Primary public DataSource dynamicDataSource() { DynamicDataSource dataSource = new DynamicDataSource(); dataSource.setDefaultTargetDataSource(test1()); Map<Object, Object> dataSourceMap = new HashMap<>(2); dataSourceMap.put(DataSourceEnum.TEST1.getName(), test1()); dataSourceMap.put(DataSourceEnum.TEST2.getName(), test2()); dataSource.setTargetDataSources(dataSourceMap); return dataSource ; } @Bean public PlatformTransactionManager transactionManager() { return new DataSourceTransactionManager(dynamicDataSource()); } } ``` DataSourceEnum ``` package com.common.db; import lombok.AllArgsConstructor; import lombok.Getter; @AllArgsConstructor @Getter public enum DataSourceEnum { DEFAULT("test1"), TEST1("test1"), TEST2("test2"); private String name; } ``` DataSourceHolder ``` package com.common.db; public class DataSourceHolder { private static final ThreadLocal<String> DS_HOLDER = new ThreadLocal<>(); public static void setDataSource(DataSourceEnum dataSource) { DS_HOLDER.set(dataSource.getName()); } public static String getDataSource() { return DS_HOLDER.get(); } public static void clearDataSource() { DS_HOLDER.remove(); } } ``` DataSourceSet ``` package com.common.db; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) @Documented public @interface DataSourceSet { //枚举 DataSourceEnum value(); } ``` DynamicDataSource ``` package com.common.db; import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource; public class DynamicDataSource extends AbstractRoutingDataSource { @Override protected Object determineCurrentLookupKey() { //基于aop切换数据源 System.out.println("dynamic datasource 切换数据源" + DataSourceHolder.getDataSource()); return DataSourceHolder.getDataSource(); } } ``` 测试调用 ``` server层 @Override @DataSourceSet(DataSourceEnum.TEST1) public String test1(Long id) { String s = programRepository.findids(id); System.out.println(s); return s; } @Override @DataSourceSet(DataSourceEnum.TEST2) public String test2(Long id) { String s = testRepository.findids1(id); System.out.println(s); return s; } ``` ``` Controller层 @PostMapping("/test") @ResponseBody public ResultVo test(Long id) { id = 1l; String beProgram1 = programService.test1(id); System.out.println(222); id=2l; String beProgram = testService.test2(id); System.out.println(333); return ResultVoUtil.success(beProgram+beProgram1); } ```
spring 整合 redis 报错
错误代码: aused by: java.lang.NoSuchMethodError: org.springframework.util.Assert.isTrue(ZLjava/util/function/Supplier;)V at org.springframework.data.redis.connection.RedisStandaloneConfiguration.<init>(RedisStandaloneConfiguration.java:65) ~[spring-data-redis-2.1.8.RELEASE.jar:2.1.8.RELEASE] at org.springframework.data.redis.connection.jedis.JedisConnectionFactory.<init>(JedisConnectionFactory.java:93) ~[spring-data-redis-2.1.8.RELEASE.jar:2.1.8.RELEASE] at org.springframework.data.redis.connection.jedis.JedisConnectionFactory.<init>(JedisConnectionFactory.java:106) ~[spring-data-redis-2.1.8.RELEASE.jar:2.1.8.RELEASE] at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_162] at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[na:1.8.0_162] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.8.0_162] at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[na:1.8.0_162] at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:147) ~[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE] ... 60 common frames omitted 我的maven <dependency> <groupId>ch.qos.logback</groupId> <artifactId>logback-classic</artifactId> <version>1.1.1</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>1.7.22</version> </dependency> <!-- 2.数据库 --> <dependency> <groupId>c3p0</groupId> <artifactId>c3p0</artifactId> <version>0.9.1.2</version> </dependency> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis</artifactId> <version>3.3.0</version> </dependency> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis-spring</artifactId> <version>1.2.3</version> </dependency> <dependency> <groupId>redis.clients</groupId> <artifactId>jedis</artifactId> <version>2.9.3</version> </dependency> <dependency> <groupId>org.springframework.data</groupId> <artifactId>spring-data-redis</artifactId> <version>2.1.8.RELEASE</version> </dependency> <dependency> <groupId>taglibs</groupId> <artifactId>standard</artifactId> <version>1.1.2</version> </dependency> <dependency> <groupId>jstl</groupId> <artifactId>jstl</artifactId> <version>1.2</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> <version>2.5.4</version> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <version>3.1.0</version> </dependency> <dependency> <groupId>commons-fileupload</groupId> <artifactId>commons-fileupload</artifactId> <version>1.2.2</version> </dependency> <dependency> <groupId>org.aspectj</groupId> <artifactId>aspectjweaver</artifactId> <version>1.7.1</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> <version>5.1.8.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-aop</artifactId> <version>5.1.8.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context-support</artifactId> <version>5.1.8.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-beans</artifactId> <version>5.1.8.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>5.1.8.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-jdbc</artifactId> <version>5.1.8.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-tx</artifactId> <version>5.1.8.RELEASE</version> </dependency> <!-- 3)Spring web --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> <version>5.1.8.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>5.1.8.RELEASE</version> </dependency> <!-- 4)Spring test --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-test</artifactId> <version>5.1.8.RELEASE</version> </dependency> <!-- Map工具类 --> <dependency> <groupId>commons-collections</groupId> <artifactId>commons-collections</artifactId> <version>3.2</version> </dependency> <!-- swagger2 --> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger2</artifactId> <version>2.8.0</version> </dependency> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger-ui</artifactId> <version>2.8.0</version> </dependency> <!--lombok --> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <version>1.16.22</version> </dependency> <!-- JSON --> <dependency> <groupId>com.alibaba</groupId> <artifactId>fastjson</artifactId> <version>1.2.37</version> </dependency> <dependency> <groupId>com.thetransactioncompany</groupId> <artifactId>cors-filter</artifactId> <version>2.5</version> </dependency> <!--<dependency>--> <!--<groupId>org.springframework.boot</groupId>--> <!--<artifactId>spring-boot-devtools</artifactId>--> <!--<optional>true</optional>--> <!--<scope>true</scope>--> <!--</dependency>--> <!-- shiro --> <dependency> <groupId>org.apache.shiro</groupId> <artifactId>shiro-core</artifactId> <version>1.4.1</version> </dependency> <dependency> <groupId>org.apache.shiro</groupId> <artifactId>shiro-web</artifactId> <version>1.4.1</version> </dependency> <dependency> <groupId>org.apache.shiro</groupId> <artifactId>shiro-ehcache</artifactId> <version>1.4.1</version> </dependency> <dependency> <groupId>org.apache.shiro</groupId> <artifactId>shiro-quartz</artifactId> <version>1.4.1</version> </dependency> <dependency> <groupId>org.apache.shiro</groupId> <artifactId>shiro-spring</artifactId> <version>1.4.1</version> </dependency> <dependency> <groupId>com.alibaba</groupId> <artifactId>druid</artifactId> <version>1.1.10</version> </dependency>--> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.1.6</version> </dependency> 我明明使用的是spring5版本的 为什么老是报出spring4.1.7的呢
为什么我配置Spring的事务后不能得到BEAN
我配置Spring的事务后不能得到BEAN 如果把事务的部分去掉的话就能够得到 下面这是applicationContext.xml [code="xml"] <?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:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd "> <bean id="myDataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName" value="net.sourceforge.jtds.jdbc.Driver"></property> <property name="url" value="jdbc:jtds:sqlserver://localhost:1433/soft2005"></property> <property name="username" value="sa"></property> <property name="password" value=""></property> </bean> <bean id="SessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource" ref="myDataSource"></property> <property name="mappingResources"> <list> <value>com/yhwj/secsms/po/Cgnx.hbm.xml</value> </list> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect"> org.hibernate.dialect.SybaseDialect </prop> </props> </property> </bean> <bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="SessionFactory"></property> </bean> <tx:advice id="myadvice" transaction-manager="txManager"> <tx:attributes> <tx:method name="*" /> </tx:attributes> </tx:advice> <aop:config> <!-- <aop:pointcut id="myPoin" expression="execution(* com.yhwj.secsms.dao.CgnxDAO.*(..))"/> <aop:advisor id="myAdvi" advice-ref="myadvice" pointcut-ref="myPoin"/> --> <aop:advisor pointcut="execution(* com.yhwj.secsms.dao.CgnxDAO.*(..))" advice-ref="myadvice"/> </aop:config> <bean id="CgnxDAO" class="com.yhwj.secsms.dao.CgnxDAO"> <property name="sessionFactory"> <ref bean="SessionFactory" /> </property> </bean></beans> [/code] 下面是测试类cgnxTest.java [code="java"] package com.yhwj.secsms.bo; import java.util.Iterator; import java.util.List; import org.springframework.context.ApplicationContext; import org.springframework.context.support.FileSystemXmlApplicationContext; import com.yhwj.secsms.dao.CgnxDAO; import com.yhwj.secsms.po.Cgnx; import junit.framework.TestCase; public class cgnxTest extends TestCase { ApplicationContext ac=new FileSystemXmlApplicationContext("src/applicationContext.xml"); public void testCgnxAddFind() { CgnxDAO cdao=(CgnxDAO) ac.getBean("CgnxDAO"); com.yhwj.secsms.vo.Cgnx cg=new com.yhwj.secsms.vo.Cgnx(); cg.setCgnx("12年"); Cgnx cg1=(Cgnx) cg.getPO(); cdao.save(cg1); List l=cdao.findAll(); assertTrue(l.size()>0); } } [/code] 下面的是运行后LOG4J抓的东西 INFO - Refreshing org.springframework.context.support.FileSystemXmlApplicationContext@8f4fb3: display name [org.springframework.context.support.FileSystemXmlApplicationContext@8f4fb3]; startup date [Wed Jul 02 09:09:49 CST 2008]; root of context hierarchy DEBUG - Class [org.apache.commons.collections.map.LinkedMap] or one of its dependencies is not present: java.lang.ClassNotFoundException: org.apache.commons.collections.map.LinkedMap DEBUG - Creating [java.util.concurrent.ConcurrentHashMap] DEBUG - Creating [java.util.LinkedHashSet] DEBUG - Creating [java.util.LinkedHashMap] DEBUG - Creating [java.util.LinkedHashSet] DEBUG - Creating [java.util.concurrent.ConcurrentHashMap] DEBUG - Creating [java.util.concurrent.ConcurrentHashMap] DEBUG - Loading schema mappings from [META-INF/spring.schemas] DEBUG - Loaded schema mappings: {http://www.springframework.org/schema/aop/spring-aop-2.0.xsd=org/springframework/aop/config/spring-aop-2.0.xsd, http://www.springframework.org/schema/util/spring-util.xsd=org/springframework/beans/factory/xml/spring-util-2.0.xsd, http://www.springframework.org/schema/util/spring-util-2.0.xsd=org/springframework/beans/factory/xml/spring-util-2.0.xsd, http://www.springframework.org/schema/jee/spring-jee.xsd=org/springframework/ejb/config/spring-jee-2.0.xsd, http://www.springframework.org/schema/beans/spring-beans.xsd=org/springframework/beans/factory/xml/spring-beans-2.0.xsd, http://www.springframework.org/schema/lang/spring-lang-2.0.xsd=org/springframework/scripting/config/spring-lang-2.0.xsd, http://www.springframework.org/schema/tx/spring-tx-2.0.xsd=org/springframework/transaction/config/spring-tx-2.0.xsd, http://www.springframework.org/schema/lang/spring-lang.xsd=org/springframework/scripting/config/spring-lang-2.0.xsd, http://www.springframework.org/schema/tool/spring-tool.xsd=org/springframework/beans/factory/xml/spring-tool-2.0.xsd, http://www.springframework.org/schema/aop/spring-aop.xsd=org/springframework/aop/config/spring-aop-2.0.xsd, http://www.springframework.org/schema/tx/spring-tx.xsd=org/springframework/transaction/config/spring-tx-2.0.xsd, http://www.springframework.org/schema/tool/spring-tool-2.0.xsd=org/springframework/beans/factory/xml/spring-tool-2.0.xsd, http://www.springframework.org/schema/jee/spring-jee-2.0.xsd=org/springframework/ejb/config/spring-jee-2.0.xsd, http://www.springframework.org/schema/beans/spring-beans-2.0.xsd=org/springframework/beans/factory/xml/spring-beans-2.0.xsd} DEBUG - Loading schema mappings from [META-INF/spring.schemas] DEBUG - Loaded schema mappings: {http://www.springframework.org/schema/aop/spring-aop-2.0.xsd=org/springframework/aop/config/spring-aop-2.0.xsd, http://www.springframework.org/schema/util/spring-util.xsd=org/springframework/beans/factory/xml/spring-util-2.0.xsd, http://www.springframework.org/schema/util/spring-util-2.0.xsd=org/springframework/beans/factory/xml/spring-util-2.0.xsd, http://www.springframework.org/schema/jee/spring-jee.xsd=org/springframework/ejb/config/spring-jee-2.0.xsd, http://www.springframework.org/schema/beans/spring-beans.xsd=org/springframework/beans/factory/xml/spring-beans-2.0.xsd, http://www.springframework.org/schema/lang/spring-lang-2.0.xsd=org/springframework/scripting/config/spring-lang-2.0.xsd, http://www.springframework.org/schema/tx/spring-tx-2.0.xsd=org/springframework/transaction/config/spring-tx-2.0.xsd, http://www.springframework.org/schema/lang/spring-lang.xsd=org/springframework/scripting/config/spring-lang-2.0.xsd, http://www.springframework.org/schema/tool/spring-tool.xsd=org/springframework/beans/factory/xml/spring-tool-2.0.xsd, http://www.springframework.org/schema/aop/spring-aop.xsd=org/springframework/aop/config/spring-aop-2.0.xsd, http://www.springframework.org/schema/tx/spring-tx.xsd=org/springframework/transaction/config/spring-tx-2.0.xsd, http://www.springframework.org/schema/tool/spring-tool-2.0.xsd=org/springframework/beans/factory/xml/spring-tool-2.0.xsd, http://www.springframework.org/schema/jee/spring-jee-2.0.xsd=org/springframework/ejb/config/spring-jee-2.0.xsd, http://www.springframework.org/schema/beans/spring-beans-2.0.xsd=org/springframework/beans/factory/xml/spring-beans-2.0.xsd} INFO - Loading XML bean definitions from file [F:\自助设备客户服务管理系统\工程\src\applicationContext.xml] DEBUG - Using JAXP provider [org.apache.xerces.jaxp.DocumentBuilderFactoryImpl] DEBUG - Trying to resolve XML entity with public id [null] and system id [http://www.springframework.org/schema/beans/spring-beans-2.0.xsd] DEBUG - Found XML schema [http://www.springframework.org/schema/beans/spring-beans-2.0.xsd] in classpath: org/springframework/beans/factory/xml/spring-beans-2.0.xsd DEBUG - Trying to resolve XML entity with public id [null] and system id [http://www.springframework.org/schema/tx/spring-tx-2.0.xsd] DEBUG - Found XML schema [http://www.springframework.org/schema/tx/spring-tx-2.0.xsd] in classpath: org/springframework/transaction/config/spring-tx-2.0.xsd DEBUG - Trying to resolve XML entity with public id [null] and system id [http://www.springframework.org/schema/aop/spring-aop-2.0.xsd] DEBUG - Found XML schema [http://www.springframework.org/schema/aop/spring-aop-2.0.xsd] in classpath: org/springframework/aop/config/spring-aop-2.0.xsd DEBUG - Loaded mappings [{http://www.springframework.org/schema/p=org.springframework.beans.factory.xml.SimplePropertyNamespaceHandler, http://www.springframework.org/schema/lang=org.springframework.scripting.config.LangNamespaceHandler, http://www.springframework.org/schema/jee=org.springframework.ejb.config.JeeNamespaceHandler, http://www.springframework.org/schema/aop=org.springframework.aop.config.AopNamespaceHandler, http://www.springframework.org/schema/util=org.springframework.beans.factory.xml.UtilNamespaceHandler, http://www.springframework.org/schema/tx=org.springframework.transaction.config.TxNamespaceHandler}] DEBUG - Loading bean definitions DEBUG - Creating [java.util.LinkedHashMap] DEBUG - Loaded 8 bean definitions from location pattern [src/applicationContext.xml] INFO - Bean factory for application context [org.springframework.context.support.FileSystemXmlApplicationContext@8f4fb3]: org.springframework.beans.factory.support.DefaultListableBeanFactory@16c9867 DEBUG - 8 beans defined in org.springframework.context.support.FileSystemXmlApplicationContext@8f4fb3: display name [org.springframework.context.support.FileSystemXmlApplicationContext@8f4fb3]; startup date [Wed Jul 02 09:09:49 CST 2008]; root of context hierarchy DEBUG - Creating shared instance of singleton bean 'org.springframework.aop.config.internalAutoProxyCreator' DEBUG - Creating instance of bean 'org.springframework.aop.config.internalAutoProxyCreator' with merged definition [Root bean: class [org.springframework.aop.aspectj.autoproxy.AspectJAwareAdvisorAutoProxyCreator]; scope=singleton; abstract=false; lazyInit=false; autowireCandidate=true; autowireMode=0; dependencyCheck=0; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null] DEBUG - Getting BeanInfo for class [org.springframework.aop.aspectj.autoproxy.AspectJAwareAdvisorAutoProxyCreator] DEBUG - Caching PropertyDescriptors for class [org.springframework.aop.aspectj.autoproxy.AspectJAwareAdvisorAutoProxyCreator] DEBUG - Found bean property 'advisorAdapterRegistry' of type [org.springframework.aop.framework.adapter.AdvisorAdapterRegistry] DEBUG - Found bean property 'applyCommonInterceptorsFirst' of type [boolean] DEBUG - Found bean property 'beanClassLoader' of type [java.lang.ClassLoader] DEBUG - Found bean property 'beanFactory' of type [org.springframework.beans.factory.BeanFactory] DEBUG - Found bean property 'class' of type [java.lang.Class] DEBUG - Found bean property 'customTargetSourceCreators' of type [[Lorg.springframework.aop.framework.autoproxy.TargetSourceCreator;] DEBUG - Found bean property 'exposeProxy' of type [boolean] DEBUG - Found bean property 'frozen' of type [boolean] DEBUG - Found bean property 'interceptorNames' of type [[Ljava.lang.String;] DEBUG - Found bean property 'opaque' of type [boolean] DEBUG - Found bean property 'optimize' of type [boolean] DEBUG - Found bean property 'order' of type [int] DEBUG - Found bean property 'proxyTargetClass' of type [boolean] DEBUG - Creating [java.util.LinkedHashMap] DEBUG - Eagerly caching bean 'org.springframework.aop.config.internalAutoProxyCreator' to allow for resolving potential circular references INFO - Bean 'org.springframework.aop.config.internalAutoProxyCreator' is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) DEBUG - Unable to locate MessageSource with name 'messageSource': using default [org.springframework.context.support.DelegatingMessageSource@148662] DEBUG - Creating [java.util.LinkedHashSet] DEBUG - Unable to locate ApplicationEventMulticaster with name 'applicationEventMulticaster': using default [org.springframework.context.event.SimpleApplicationEventMulticaster@178460d] DEBUG - Creating [java.util.LinkedHashMap] INFO - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@16c9867: defining beans [myDataSource,SessionFactory,txManager,myadvice,org.springframework.aop.config.internalAutoProxyCreator,org.springframework.aop.aspectj.AspectJExpressionPointcut,org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor,CgnxDAO]; root of factory hierarchy DEBUG - Creating shared instance of singleton bean 'myDataSource' DEBUG - Creating instance of bean 'myDataSource' with merged definition [Root bean: class [org.springframework.jdbc.datasource.DriverManagerDataSource]; scope=singleton; abstract=false; lazyInit=false; autowireCandidate=true; autowireMode=0; dependencyCheck=0; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in file [F:\自助设备客户服务管理系统\工程\src\applicationContext.xml]] DEBUG - Getting BeanInfo for class [org.springframework.jdbc.datasource.DriverManagerDataSource] DEBUG - Caching PropertyDescriptors for class [org.springframework.jdbc.datasource.DriverManagerDataSource] DEBUG - Found bean property 'class' of type [java.lang.Class] DEBUG - Found bean property 'connection' of type [java.sql.Connection] DEBUG - Found bean property 'connectionProperties' of type [java.util.Properties] DEBUG - Found bean property 'driverClassName' of type [java.lang.String] DEBUG - Found bean property 'logWriter' of type [java.io.PrintWriter] DEBUG - Found bean property 'loginTimeout' of type [int] DEBUG - Found bean property 'password' of type [java.lang.String] DEBUG - Found bean property 'url' of type [java.lang.String] DEBUG - Found bean property 'username' of type [java.lang.String] DEBUG - Creating [java.util.LinkedHashMap] DEBUG - Eagerly caching bean 'myDataSource' to allow for resolving potential circular references INFO - Loaded JDBC driver: net.sourceforge.jtds.jdbc.Driver DEBUG - Creating shared instance of singleton bean 'org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor' DEBUG - Creating instance of bean 'org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor' with merged definition [Root bean: class [org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor]; scope=singleton; abstract=false; lazyInit=false; autowireCandidate=true; autowireMode=0; dependencyCheck=0; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null] DEBUG - Did not attempt to auto-proxy infrastructure class [org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor] DEBUG - Getting BeanInfo for class [org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor] DEBUG - Caching PropertyDescriptors for class [org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor] DEBUG - Found bean property 'advice' of type [org.aopalliance.aop.Advice] DEBUG - Found bean property 'adviceBeanName' of type [java.lang.String] DEBUG - Found bean property 'beanFactory' of type [org.springframework.beans.factory.BeanFactory] DEBUG - Found bean property 'class' of type [java.lang.Class] DEBUG - Found bean property 'order' of type [int] DEBUG - Found bean property 'perInstance' of type [boolean] DEBUG - Found bean property 'pointcut' of type [org.springframework.aop.Pointcut] DEBUG - Creating [java.util.LinkedHashMap] DEBUG - Eagerly caching bean 'org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor' to allow for resolving potential circular references DEBUG - Creating instance of bean 'org.springframework.aop.aspectj.AspectJExpressionPointcut' with merged definition [Root bean: class [org.springframework.aop.aspectj.AspectJExpressionPointcut]; scope=prototype; abstract=false; lazyInit=false; autowireCandidate=true; autowireMode=0; dependencyCheck=0; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null] DEBUG - Getting BeanInfo for class [org.springframework.aop.aspectj.AspectJExpressionPointcut] DEBUG - Caching PropertyDescriptors for class [org.springframework.aop.aspectj.AspectJExpressionPointcut] DEBUG - Found bean property 'class' of type [java.lang.Class] DEBUG - Found bean property 'classFilter' of type [org.springframework.aop.ClassFilter] DEBUG - Found bean property 'expression' of type [java.lang.String] DEBUG - Found bean property 'location' of type [java.lang.String] DEBUG - Found bean property 'methodMatcher' of type [org.springframework.aop.MethodMatcher] DEBUG - Found bean property 'parameterNames' of type [[Ljava.lang.String;] DEBUG - Found bean property 'parameterTypes' of type [[Ljava.lang.Class;] DEBUG - Found bean property 'pointcutDeclarationScope' of type [java.lang.Class] DEBUG - Found bean property 'pointcutExpression' of type [org.aspectj.weaver.tools.PointcutExpression] DEBUG - Found bean property 'runtime' of type [boolean] DEBUG - Creating [java.util.LinkedHashMap] DEBUG - Creating [java.util.LinkedHashSet] DEBUG - Creating shared instance of singleton bean 'SessionFactory' DEBUG - Creating instance of bean 'SessionFactory' with merged definition [Root bean: class [org.springframework.orm.hibernate3.LocalSessionFactoryBean]; scope=singleton; abstract=false; lazyInit=false; autowireCandidate=true; autowireMode=0; dependencyCheck=0; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in file [F:\自助设备客户服务管理系统\工程\src\applicationContext.xml]] DEBUG - Getting BeanInfo for class [org.springframework.orm.hibernate3.LocalSessionFactoryBean] DEBUG - Caching PropertyDescriptors for class [org.springframework.orm.hibernate3.LocalSessionFactoryBean] DEBUG - Found bean property 'cacheableMappingLocations' of type [[Lorg.springframework.core.io.Resource;] DEBUG - Found bean property 'class' of type [java.lang.Class] DEBUG - Found bean property 'collectionCacheStrategies' of type [java.util.Properties] DEBUG - Found bean property 'configLocation' of type [org.springframework.core.io.Resource] DEBUG - Found bean property 'configLocations' of type [[Lorg.springframework.core.io.Resource;] DEBUG - Found bean property 'configuration' of type [org.hibernate.cfg.Configuration] DEBUG - Found bean property 'configurationClass' of type [java.lang.Class] DEBUG - Found bean property 'dataSource' of type [javax.sql.DataSource] DEBUG - Found bean property 'entityCacheStrategies' of type [java.util.Properties] DEBUG - Found bean property 'entityInterceptor' of type [org.hibernate.Interceptor] DEBUG - Found bean property 'eventListeners' of type [java.util.Map] DEBUG - Found bean property 'exposeTransactionAwareSessionFactory' of type [boolean] DEBUG - Found bean property 'filterDefinitions' of type [[Lorg.hibernate.engine.FilterDefinition;] DEBUG - Found bean property 'hibernateProperties' of type [java.util.Properties] DEBUG - Found bean property 'jdbcExceptionTranslator' of type [org.springframework.jdbc.support.SQLExceptionTranslator] DEBUG - Found bean property 'jtaTransactionManager' of type [javax.transaction.TransactionManager] DEBUG - Found bean property 'lobHandler' of type [org.springframework.jdbc.support.lob.LobHandler] DEBUG - Found bean property 'mappingDirectoryLocations' of type [[Lorg.springframework.core.io.Resource;] DEBUG - Found bean property 'mappingJarLocations' of type [[Lorg.springframework.core.io.Resource;] DEBUG - Found bean property 'mappingLocations' of type [[Lorg.springframework.core.io.Resource;] DEBUG - Found bean property 'mappingResources' of type [[Ljava.lang.String;] DEBUG - Found bean property 'namingStrategy' of type [org.hibernate.cfg.NamingStrategy] DEBUG - Found bean property 'object' of type [java.lang.Object] DEBUG - Found bean property 'objectType' of type [java.lang.Class] DEBUG - Found bean property 'schemaUpdate' of type [boolean] DEBUG - Found bean property 'singleton' of type [boolean] DEBUG - Found bean property 'typeDefinitions' of type [[Lorg.springframework.orm.hibernate3.TypeDefinitionBean;] DEBUG - Found bean property 'useTransactionAwareDataSource' of type [boolean] DEBUG - Creating [java.util.LinkedHashMap] DEBUG - Eagerly caching bean 'SessionFactory' to allow for resolving potential circular references DEBUG - Returning cached instance of singleton bean 'myDataSource' DEBUG - Creating [java.util.LinkedHashSet] DEBUG - Creating [java.util.LinkedHashMap] INFO - Hibernate 3.1.3 INFO - hibernate.properties not found INFO - using CGLIB reflection optimizer INFO - using JDK 1.4 java.sql.Timestamp handling DEBUG - trying to resolve system-id [http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd] DEBUG - recognized hibernate namespace; attempting to resolve on classpath under org/hibernate/ DEBUG - located [http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd] in classpath INFO - Mapping class: com.yhwj.secsms.po.Cgnx -> cgnx DEBUG - Mapped property: cgnxId -> cgnxID DEBUG - Mapped property: cgnx -> cgnx INFO - Building new Hibernate SessionFactory DEBUG - Preparing to build session factory with filters : {} DEBUG - processing extends queue DEBUG - processing collection mappings DEBUG - processing native query and ResultSetMapping mappings DEBUG - processing association property references DEBUG - processing foreign key constraints INFO - Initializing connection provider: org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider DEBUG - Creating new JDBC Connection to [jdbc:jtds:sqlserver://localhost:1433/soft2005] INFO - RDBMS: Microsoft SQL Server, version: 08.00.2039 INFO - JDBC driver: jTDS Type 4 JDBC Driver for MS SQL Server and Sybase, version: 1.2.2 INFO - Using dialect: org.hibernate.dialect.SybaseDialect INFO - Using default transaction strategy (direct JDBC transactions) INFO - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended) INFO - Automatic flush during beforeCompletion(): disabled INFO - Automatic session close at end of transaction: disabled INFO - Scrollable result sets: enabled DEBUG - Wrap result sets: disabled INFO - JDBC3 getGeneratedKeys(): enabled INFO - Connection release mode: on_close INFO - Default batch fetch size: 1 INFO - Generate SQL with comments: disabled INFO - Order SQL updates by primary key: disabled INFO - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory INFO - Using ASTQueryTranslatorFactory INFO - Query language substitutions: {} INFO - Second-level cache: enabled INFO - Query cache: disabled INFO - Cache provider: org.hibernate.cache.EhCacheProvider INFO - Optimize cache for minimal puts: disabled INFO - Structured second-level cache entries: disabled DEBUG - Using dialect defined converter INFO - Statistics: disabled INFO - Deleted entity synthetic identifier rollback: disabled INFO - Default entity-mode: pojo INFO - building session factory DEBUG - Session factory constructed with filter configurations : {} DEBUG - instantiating session factory with properties: {java.runtime.name=Java(TM) 2 Runtime Environment, Standard Edition, sun.boot.library.path=D:\Program Files\MyEclipse 5.5 GA\jre\bin, java.vm.version=1.5.0_11-b03, java.vm.vendor=Sun Microsystems Inc., java.vendor.url=http://java.sun.com/, path.separator=;, java.vm.name=Java HotSpot(TM) Client VM, file.encoding.pkg=sun.io, user.country=CN, sun.java.launcher=SUN_STANDARD, sun.os.patch.level=Service Pack 3, java.vm.specification.name=Java Virtual Machine Specification, user.dir=F:\自助设备客户服务管理系统\工程, java.runtime.version=1.5.0_11-b03, java.awt.graphicsenv=sun.awt.Win32GraphicsEnvironment, java.endorsed.dirs=D:\Program Files\MyEclipse 5.5 GA\jre\lib\endorsed, os.arch=x86, java.io.tmpdir=C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\, line.separator= , java.vm.specification.vendor=Sun Microsystems Inc., user.variant=, os.name=Windows XP, sun.jnu.encoding=GBK, java.library.path=D:\Program Files\MyEclipse 5.5 GA\jre\bin;.;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\Java\jdk1.5.0_07\\bin;C:\Program Files\Microsoft SQL Server\80\Tools\BINN;C:\Program Files\StormII\Codec;C:\Program Files\StormII, java.specification.name=Java Platform API Specification, java.class.version=49.0, sun.management.compiler=HotSpot Client Compiler, os.version=5.1, user.home=C:\Documents and Settings\Administrator, user.timezone=Asia/Shanghai, hibernate.connection.release_mode=on_close, java.awt.printerjob=sun.awt.windows.WPrinterJob, file.encoding=GBK, java.specification.version=1.5, java.class.path=F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\classes;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\jstl.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\standard.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\antlr-2.7.6rc1.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\asm-attrs.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\asm.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\c3p0-0.9.0.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\cglib-2.1.3.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\commons-collections-2.1.1.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\commons-logging-1.0.4.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\concurrent-1.3.2.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\connector.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\dom4j-1.6.1.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\ehcache-1.1.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\hibernate3.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\jaas.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\jacc-1_0-fr.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\jaxen-1.1-beta-7.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\jboss-cache.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\jboss-common.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\jboss-jmx.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\jboss-system.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\jdbc2_0-stdext.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\jgroups-2.2.8.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\jta.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\jtds-1.2.2.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\log4j-1.2.11.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\oscache-2.1.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\proxool-0.8.3.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\swarmcache-1.0rc2.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\xerces-2.6.2.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\xml-apis.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\aopalliance.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\asm-2.2.3.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\asm-commons-2.2.3.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\asm-util-2.2.3.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\aspectjrt.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\aspectjweaver.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\backport-util-concurrent.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\bsh-2.0b4.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\c3p0-0.9.1.1.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\cglib-nodep-2.1_3.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\commonj-twm.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\commons-attributes-api.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\commons-attributes-compiler.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\commons-dbcp.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\commons-lang.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\commons-logging.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\ehcache-1.2.4.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\groovy-1.0.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\hessian-3.0.20.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\hibernate-annotations.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\hibernate-commons-annotations.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\hibernate-entitymanager.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\ibatis-2.3.0.677.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\jakarta-oro-2.0.8.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\jamon-2.4.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\jboss-archive-browsing.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\jdo2-api.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\jmxremote.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\jmxremote_optional.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\jmxri.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\jotm.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\jruby.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\log4j-1.2.14.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\openjpa-0.9.7-incubating.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\persistence.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\quartz-all-1.6.0.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\serp-1.12.1.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\spring-agent.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\spring-aop.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\spring-beans.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\spring-context.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\spring-core.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\spring-dao.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\spring-hibernate3.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\spring-ibatis.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\spring-jdbc.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\spring-jdo.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\spring-jmx.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\spring-jpa.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\spring-remoting.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\spring-support.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\spring-tomcat-weaver.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\spring-toplink.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\toplink-api.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\toplink-essentials.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\xapool.jar;D:\Program Files\MyEclipse 5.5 GA\eclipse\plugins\org.junit_3.8.1\junit.jar;/D:/Program Files/MyEclipse 5.5 GA/eclipse/plugins/org.eclipse.jdt.junit_3.2.1.r321_v20060810/junitsupport.jar;/D:/Program Files/MyEclipse 5.5 GA/eclipse/plugins/org.eclipse.jdt.junit.runtime_3.2.1.r321_v20060721/junitruntime.jar, user.name=Administrator, java.vm.specification.version=1.0, sun.arch.data.model=32, java.home=D:\Program Files\MyEclipse 5.5 GA\jre, hibernate.dialect=org.hibernate.dialect.SybaseDialect, java.specification.vendor=Sun Microsystems Inc., user.language=zh, awt.toolkit=sun.awt.windows.WToolkit, java.vm.info=mixed mode, hibernate.cglib.use_reflection_optimizer=true, java.version=1.5.0_11, java.ext.dirs=D:\Program Files\MyEclipse 5.5 GA\jre\lib\ext, sun.boot.class.path=D:\Program Files\MyEclipse 5.5 GA\jre\lib\rt.jar;D:\Program Files\MyEclipse 5.5 GA\jre\lib\i18n.jar;D:\Program Files\MyEclipse 5.5 GA\jre\lib\sunrsasign.jar;D:\Program Files\MyEclipse 5.5 GA\jre\lib\jsse.jar;D:\Program Files\MyEclipse 5.5 GA\jre\lib\jce.jar;D:\Program Files\MyEclipse 5.5 GA\jre\lib\charsets.jar;D:\Program Files\MyEclipse 5.5 GA\jre\classes;D:\Program Files\MyEclipse 5.5 GA\myeclipse\eclipse\plugins\com.genuitec.eclipse.j2eedt.core_5.5.0\data\libraryset\1.4\activation.jar;D:\Program Files\MyEclipse 5.5 GA\myeclipse\eclipse\plugins\com.genuitec.eclipse.j2eedt.core_5.5.0\data\libraryset\1.4\javax.servlet.jar;D:\Program Files\MyEclipse 5.5 GA\myeclipse\eclipse\plugins\com.genuitec.eclipse.j2eedt.core_5.5.0\data\libraryset\1.4\javax.servlet.jsp.jar;D:\Program Files\MyEclipse 5.5 GA\myeclipse\eclipse\plugins\com.genuitec.eclipse.j2eedt.core_5.5.0\data\libraryset\1.4\jboss-j2ee.jar;D:\Program Files\MyEclipse 5.5 GA\myeclipse\eclipse\plugins\com.genuitec.eclipse.j2eedt.core_5.5.0\data\libraryset\1.4\jboss-jaxrpc.jar;D:\Program Files\MyEclipse 5.5 GA\myeclipse\eclipse\plugins\com.genuitec.eclipse.j2eedt.core_5.5.0\data\libraryset\1.4\jboss-jsr77.jar;D:\Program Files\MyEclipse 5.5 GA\myeclipse\eclipse\plugins\com.genuitec.eclipse.j2eedt.core_5.5.0\data\libraryset\1.4\jboss-saaj.jar;D:\Program Files\MyEclipse 5.5 GA\myeclipse\eclipse\plugins\com.genuitec.eclipse.j2eedt.core_5.5.0\data\libraryset\1.4\mail.jar;D:\Program Files\MyEclipse 5.5 GA\myeclipse\eclipse\plugins\com.genuitec.eclipse.j2eedt.core_5.5.0\data\libraryset\1.4\namespace.jar;D:\Program Files\MyEclipse 5.5 GA\myeclipse\eclipse\plugins\com.genuitec.eclipse.j2eedt.core_5.5.0\data\libraryset\1.4\xml-apis.jar, java.vendor=Sun Microsystems Inc., file.separator=\, java.vendor.url.bug=http://java.sun.com/cgi-bin/bugreport.cgi, hibernate.connection.provider_class=org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider, sun.cpu.endian=little, sun.io.unicode.encoding=UnicodeLittle, sun.desktop=windows, sun.cpu.isalist=pentium_pro+mmx pentium_pro pentium+mmx pentium i486 i386 i86} DEBUG - Creating new CacheManager with default config DEBUG - Configuring ehcache from classpath. WARN - No configuration found. Configuring ehcache from ehcache-failsafe.xml found in the classpath: jar:file:/F:/%e8%87%aa%e5%8a%a9%e8%ae%be%e5%a4%87%e5%ae%a2%e6%88%b7%e6%9c%8d%e5%8a%a1%e7%ae%a1%e7%90%86%e7%b3%bb%e7%bb%9f/%e5%b7%a5%e7%a8%8b/WebRoot/WEB-INF/lib/ehcache-1.1.jar!/ehcache-failsafe.xml DEBUG - Disk Store Path: C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\ DEBUG - Static SQL for entity: com.yhwj.secsms.po.Cgnx DEBUG - Version select: select cgnxID from secsms.dbo.cgnx where cgnxID =? DEBUG - Snapshot select: select cgnx_.cgnxID, cgnx_.cgnx as cgnx0_ from secsms.dbo.cgnx cgnx_ where cgnx_.cgnxID=? DEBUG - Insert 0: insert into secsms.dbo.cgnx (cgnx, cgnxID) values (?, ?) DEBUG - Update 0: update secsms.dbo.cgnx set cgnx=? where cgnxID=? DEBUG - Delete 0: delete from secsms.dbo.cgnx where cgnxID=? DEBUG - Identity insert: insert into secsms.dbo.cgnx (cgnx) values (?) DEBUG - Static select for entity com.yhwj.secsms.po.Cgnx: select cgnx0_.cgnxID as cgnxID0_0_, cgnx0_.cgnx as cgnx0_0_ from secsms.dbo.cgnx cgnx0_ where cgnx0_.cgnxID=? DEBUG - Static select for entity com.yhwj.secsms.po.Cgnx: select cgnx0_.cgnxID as cgnxID0_0_, cgnx0_.cgnx as cgnx0_0_ from secsms.dbo.cgnx cgnx0_ where cgnx0_.cgnxID=? DEBUG - Static select for entity com.yhwj.secsms.po.Cgnx: select cgnx0_.cgnxID as cgnxID0_0_, cgnx0_.cgnx as cgnx0_0_ from secsms.dbo.cgnx cgnx0_ where cgnx0_.cgnxID=? DEBUG - Static select for entity com.yhwj.secsms.po.Cgnx: select cgnx0_.cgnxID as cgnxID0_0_, cgnx0_.cgnx as cgnx0_0_ from secsms.dbo.cgnx cgnx0_ where cgnx0_.cgnxID=? DEBUG - Static select for action ACTION_MERGE on entity com.yhwj.secsms.po.Cgnx: select cgnx0_.cgnxID as cgnxID0_0_, cgnx0_.cgnx as cgnx0_0_ from secsms.dbo.cgnx cgnx0_ where cgnx0_.cgnxID=? DEBUG - Static select for action ACTION_REFRESH on entity com.yhwj.secsms.po.Cgnx: select cgnx0_.cgnxID as cgnxID0_0_, cgnx0_.cgnx as cgnx0_0_ from secsms.dbo.cgnx cgnx0_ where cgnx0_.cgnxID=? DEBUG - initializing class SessionFactoryObjectFactory DEBUG - registered: 4028808b1ae151ae011ae151b9410000 (unnamed) INFO - Not binding factory to JNDI, no JNDI name configured DEBUG - instantiated session factory DEBUG - Checking 0 named HQL queries DEBUG - Checking 0 named SQL queries DEBUG - Returning cached instance of singleton bean 'org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor' DEBUG - Creating shared instance of singleton bean 'txManager' DEBUG - Creating instance of bean 'txManager' with merged definition [Root bean: class [org.springframework.orm.hibernate3.HibernateTransactionManager]; scope=singleton; abstract=false; lazyInit=false; autowireCandidate=true; autowireMode=0; dependencyCheck=0; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in file [F:\自助设备客户服务管理系统\工程\src\applicationContext.xml]] DEBUG - Getting BeanInfo for class [org.springframework.orm.hibernate3.HibernateTransactionManager] DEBUG - Caching PropertyDescriptors for class [org.springframework.orm.hibernate3.HibernateTransactionManager] DEBUG - Found bean property 'autodetectDataSource' of type [boolean] DEBUG - Found bean property 'beanFactory' of type [org.springframework.beans.factory.BeanFactory] DEBUG - Found bean property 'class' of type [java.lang.Class] DEBUG - Found bean property 'dataSource' of type [javax.sql.DataSource] DEBUG - Found bean property 'defaultTimeout' of type [int] DEBUG - Found bean property 'entityInterceptor' of type [org.hibernate.Interceptor] DEBUG - Found bean property 'entityInterceptorBeanName' of type [java.lang.String] DEBUG - Found bean property 'failEarlyOnGlobalRollbackOnly' of type [boolean] DEBUG - Found bean property 'globalRollbackOnParticipationFailure' of type [boolean] DEBUG - Found bean property 'jdbcExceptionTranslator' of type [org.springframework.jdbc.support.SQLExceptionTranslator] DEBUG - Found bean property 'nestedTransactionAllowed' of type [boolean] DEBUG - Found bean property 'prepareConnection' of type [boolean] DEBUG - Found bean property 'resourceFactory' of type [java.lang.Object] DEBUG - Found bean property 'rollbackOnCommitFailure' of type [boolean] DEBUG - Found bean property 'sessionFactory' of type [org.hibernate.SessionFactory] DEBUG - Found bean property 'transactionSynchronization' of type [int] DEBUG - Found bean property 'transactionSynchronizationName' of type [java.lang.String] DEBUG - Creating [java.util.LinkedHashMap] DEBUG - Eagerly caching bean 'txManager' to allow for resolving potential circular references DEBUG - Returning cached instance of singleton bean 'SessionFactory' DEBUG - Returning cached instance of singleton bean 'org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor' DEBUG - Creating [java.util.LinkedHashSet] INFO - Using DataSource [org.springframework.jdbc.datasource.DriverManagerDataSource@76db09] of Hibernate SessionFactory for HibernateTransactionManager DEBUG - Returning cached instance of singleton bean 'org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor' DEBUG - Creating shared instance of singleton bean 'myadvice' DEBUG - Creating instance of bean 'myadvice' with merged definition [Root bean: class [org.springframework.transaction.interceptor.TransactionInterceptor]; scope=singleton; abstract=false; lazyInit=false; autowireCandidate=true; autowireMode=0; dependencyCheck=0; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null] DEBUG - Did not attempt to auto-proxy infrastructure class [org.springframework.transaction.interceptor.TransactionInterceptor] DEBUG - Getting BeanInfo for class [org.springframework.transaction.interceptor.TransactionInterceptor] DEBUG - Caching PropertyDescriptors for class [org.springframework.transaction.interceptor.TransactionInterceptor] DEBUG - Found bean property 'class' of type [java.lang.Class] DEBUG - Found bean property 'transactionAttributeSource' of type [org.springframework.transaction.interceptor.TransactionAttributeSource] DEBUG - Found bean property 'transactionAttributeSources' of type [[Lorg.springframework.transaction.interceptor.TransactionAttributeSource;] DEBUG - Found bean property 'transactionAttributes' of type [java.util.Properties] DEBUG - Found bean property 'transactionManager' of type [org.springframework.transaction.PlatformTransactionManager] DEBUG - Creating [java.util.LinkedHashMap] DEBUG - Eagerly caching bean 'myadvice' to allow for resolving potential circular references DEBUG - Returning cached instance of singleton bean 'txManager' DEBUG - Creating [java.util.LinkedHashSet] DEBUG - Creating instance of bean '(inner bean)' with merged definition [Root bean: class [org.springframework.transaction.interceptor.NameMatchTransactionAttributeSource]; scope=singleton; abstract=false; lazyInit=false; autowireCandidate=true; autowireMode=0; dependencyCheck=0; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null] DEBUG - Getting BeanInfo for class [org.springframework.transaction.interceptor.NameMatchTransactionAttributeSource] DEBUG - Caching PropertyDescriptors for class [org.springframework.transaction.interceptor.NameMatchTransactionAttributeSource] DEBUG - Found bean property 'class' of type [java.lang.Class] DEBUG - Found bean property 'nameMap' of type [java.util.Map] DEBUG - Found bean property 'properties' of type [java.util.Properties] DEBUG - Creating [java.util.LinkedHashMap] DEBUG - Creating [java.util.LinkedHashMap] DEBUG - Adding transactional method [*] with attribute [PROPAGATION_REQUIRED,ISOLATION_DEFAULT] DEBUG - Returning cached instance of singleton bean 'org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor' DEBUG - Creating [java.util.LinkedHashSet] DEBUG - Creating shared instance of singleton bean 'CgnxDAO' DEBUG - Creating instance of bean 'CgnxDAO' with merged definition [Root bean: class [com.yhwj.secsms.dao.CgnxDAO]; scope=singleton; abstract=false; lazyInit=false; autowireCandidate=true; autowireMode=0; dependencyCheck=0; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in file [F:\自助设备客户服务管理系统\工程\src\applicationContext.xml]] DEBUG - Getting BeanInfo for class [com.yhwj.secsms.dao.CgnxDAO] DEBUG - Caching PropertyDescriptors for class [com.yhwj.secsms.dao.CgnxDAO] DEBUG - Found bean property 'class' of type [java.lang.Class] DEBUG - Found bean property 'hibernateTemplate' of type [org.springframework.orm.hibernate3.HibernateTemplate] DEBUG - Found bean property 'sessionFactory' of type [org.hibernate.SessionFactory] DEBUG - Creating [java.util.LinkedHashMap] DEBUG - Eagerly caching bean 'CgnxDAO' to allow for resolving potential circular references DEBUG - Returning cached instance of singleton bean 'SessionFactory' DEBUG - Returning cached instance of singleton bean 'org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor' DEBUG - Returning cached instance of singleton bean 'myadvice' DEBUG - Creating [java.util.IdentityHashMap] DEBUG - Creating implicit proxy for bean 'CgnxDAO' with 0 common interceptors and 1 specific interceptors DEBUG - Creating JDK dynamic proxy: target source is SingletonTargetSource for target object [com.yhwj.secsms.dao.CgnxDAO@19855ed] DEBUG - Publishing event in context [org.springframework.context.support.FileSystemXmlApplicationContext@8f4fb3]: org.springframework.context.event.ContextRefreshedEvent[source=org.springframework.context.support.FileSystemXmlApplicationContext@8f4fb3: display name [org.springframework.context.support.FileSystemXmlApplicationContext@8f4fb3]; startup date [Wed Jul 02 09:09:49 CST 2008]; root of context hierarchy] DEBUG - Returning cached instance of singleton bean 'CgnxDAO'
spring3.1+ehcache配置问题
ehcache主配置如下: <!-- 配置ehcache缓存管理器 --> <bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean"> <property name="configLocation" value="classpath:ehcache/ehcache.xml" /> <property name="shared" value="true"/> </bean> <!-- 配置一个简单的缓存工厂bean对象 --> <bean id="simpleCache" class="org.springframework.cache.ehcache.EhCacheFactoryBean"> <property name="cacheManager" ref="cacheManager" /> <!-- 使用缓存 关联ehcache.xml中的缓存配置 --> <property name="cacheName" value="mobileCache" /> </bean> <!-- 配置一个缓存拦截器对象,处理具体的缓存业务 --> <bean id="methodCacheInterceptor" class="com.scxxs.ehcache.MethodCacheInterceptor"> <property name="cache" ref="simpleCache"/> </bean> <!-- 配置一个缓存拦截器对象,处理具体的缓存业务 --> <bean id="methodCacheAfterAdvice" class="com.scxxs.ehcache.MethodCacheAfterAdvice"> <property name="cache" ref="simpleCache"/> </bean> <!-- 参与缓存的切入点对象 (切入点对象,确定何时何地调用拦截器) --> <bean id="methodCachePointCut" class="org.springframework.aop.support.RegexpMethodPointcutAdvisor"> <!-- 配置缓存aop切面 --> <property name="advice" ref="methodCacheInterceptor" /> <!-- 配置哪些方法参与缓存策略 --> <!-- .表示符合任何单一字元 ### +表示符合前一个字元一次或多次 ### *表示符合前一个字元零次或多次 ### \Escape任何Regular expression使用到的符号 --> <!-- .*表示前面的前缀(包括包名) 表示print方法--> <property name="patterns"> <list> <!-- <value>com.scxxs.dao.*get*</value> <value>com.scxxs.dao.*find*</value> <value>com.scxxs.dao.*query*</value> --> <value>.*find.*</value> </list> </property> </bean> <!-- 当发生create,save,insert,update,delete,remove等方法时,就会去flush一下 --> <bean id="methodCachePointCutAdvice" class="org.springframework.aop.support.RegexpMethodPointcutAdvisor"> <property name="advice" ref="methodCacheAfterAdvice" /> <property name="patterns"> <list> <value>.*add.*</value> </list> </property> </bean> ehcache.xml配置如下: <ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="ehcache.xsd"> <!-- 设置缓存文件 .data 的创建路径。 如果该路径是 Java 系统参数,当前虚拟机会重新赋值。 下面的参数这样解释: user.home – 用户主目录 user.dir – 用户当前工作目录 java.io.tmpdir – 默认临时文件路径 --> <diskStore path="java.io.tmpdir"/> <defaultCache maxElementsInMemory="10000" eternal="false" timeToIdleSeconds="30" timeToLiveSeconds="30" overflowToDisk="false"/> <!-- 配置自定义缓存 maxElementsInMemory:缓存中允许创建的最大对象数 eternal:缓存中对象是否为永久的,如果是,超时设置将被忽略,对象从不过期。 timeToIdleSeconds:缓存数据的钝化时间,也就是在一个元素消亡之前, 两次访问时间的最大时间间隔值,这只能在元素不是永久驻留时有效, 如果该值是 0 就意味着元素可以停顿无穷长的时间。 timeToLiveSeconds:缓存数据的生存时间,也就是一个元素从构建到消亡的最大时间间隔值, 这只能在元素不是永久驻留时有效,如果该值是0就意味着元素可以停顿无穷长的时间。 overflowToDisk:内存不足时,是否启用磁盘缓存。 memoryStoreEvictionPolicy:缓存满了之后的淘汰算法。 --> <cache name="SimplePageCachingFilter" maxElementsInMemory="10000" eternal="false" overflowToDisk="false" timeToIdleSeconds="900" timeToLiveSeconds="1800" memoryStoreEvictionPolicy="LFU" /> <cache name="mobileCache" maxElementsInMemory="10000" eternal="false" overflowToDisk="true" timeToIdleSeconds="1800" timeToLiveSeconds="3600" memoryStoreEvictionPolicy="LFU" /> </ehcache> applicationContext.xml spring主配置如下: <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName"> <value>com.mysql.jdbc.Driver</value> </property> <property name="url"> <value>jdbc:mysql://127.0.0.1:3306/mytest</value> </property> <property name="username"> <value>root</value> </property> <property name="password"> <value>root</value> </property> </bean> <!-- 配置事务管理器 --> <bean id="transcationManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="dataSource" /> </bean> <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <property name="configLocation" value="classpath:ibatis/SqlMapConfig.xml" /> <!--src/ WEB-INF/<property name="mapperLocations" value="classpath*:com/xxt/ibatis/dbcp/domain/user.map.xml"/ > --> </bean> <bean id="sqlSession" class="org.mybatis.spring.SqlSessionTemplate"> <constructor-arg index="0" ref="sqlSessionFactory" /> </bean> <tx:advice id="txAdvice" transaction-manager="transcationManager"> <tx:attributes> <tx:method name="insert*" propagation="REQUIRED" /> <tx:method name="del*" propagation="REQUIRED" /> <tx:method name="update*" propagation="REQUIRED" /> <tx:method name="*" read-only="true" /> </tx:attributes> </tx:advice> <!-- 配置AOP切入点 --> <aop:config> <aop:pointcut id="allManagerMethod" expression="execution(* com.scxxs.dao.*.*(..))" /> <aop:advisor advice-ref="txAdvice" pointcut-ref="allManagerMethod" /> </aop:config> <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate"> <property name="dataSource"> <ref local="dataSource"/> </property> </bean> <import resource="spring/applicationContext_dao.xml"/> <import resource="spring/applicationContext_biz.xml"/> <import resource="spring/applicationContext_ehcache.xml"/> 我遇到的问题就是,ehcache在配置两个切面的时候报错: 2013-01-06 14:33:38Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@1aaf64d: defining beans [dataSource,transcationManager,sqlSessionFactory,sqlSession,txAdvice,org.springframework.aop.config.internalAutoProxyCreator,allManagerMethod,org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor#0,jdbcTemplate,springDemoDao,userDao,userBiz,cacheManager,simpleCache,methodCacheInterceptor,methodCacheAfterAdvice,methodCachePointCut,methodCachePointCutAdvice]; root of factory hierarchy 2013-01-06 14:33:38Retrieved dependent beans for bean 'cacheManager': [simpleCache] 2013-01-06 14:33:38Retrieved dependent beans for bean 'simpleCache': [methodCacheAfterAdvice] 2013-01-06 14:33:38Retrieved dependent beans for bean 'methodCacheAfterAdvice': [methodCachePointCutAdvice] 2013-01-06 14:33:38Invoking destroy() on bean with name 'cacheManager' 2013-01-06 14:33:38Shutting down EHCache CacheManager 2013-01-06 14:33:38Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [applicationContext.xml]: BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'methodCachePointCut' defined in class path resource [spring/applicationContext_ehcache.xml]: Cannot resolve reference to bean 'methodCacheInterceptor' while setting bean property 'advice'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'methodCacheInterceptor' defined in class path resource [spring/applicationContext_ehcache.xml]: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type '$Proxy4 implementing net.sf.ehcache.terracotta.InternalEhcache,net.sf.ehcache.store.StoreListener,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised' to required type 'net.sf.ehcache.Cache' for property 'cache'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [$Proxy4 implementing net.sf.ehcache.terracotta.InternalEhcache,net.sf.ehcache.store.StoreListener,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised] to required type [net.sf.ehcache.Cache] for property 'cache': no matching editors or conversion strategy found at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:452) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464) at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:385) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:284) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3827) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4334) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525) at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:920) at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:883) at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492) at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1138) at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053) at org.apache.catalina.core.StandardHost.start(StandardHost.java:719) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443) at org.apache.catalina.core.StandardService.start(StandardService.java:516) at org.apache.catalina.core.StandardServer.start(StandardServer.java:710) at org.apache.catalina.startup.Catalina.start(Catalina.java:566) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413) Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'methodCachePointCut' defined in class path resource [spring/applicationContext_ehcache.xml]: Cannot resolve reference to bean 'methodCacheInterceptor' while setting bean property 'advice'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'methodCacheInterceptor' defined in class path resource [spring/applicationContext_ehcache.xml]: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type '$Proxy4 implementing net.sf.ehcache.terracotta.InternalEhcache,net.sf.ehcache.store.StoreListener,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised' to required type 'net.sf.ehcache.Cache' for property 'cache'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [$Proxy4 implementing net.sf.ehcache.terracotta.InternalEhcache,net.sf.ehcache.store.StoreListener,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised] to required type [net.sf.ehcache.Cache] for property 'cache': no matching editors or conversion strategy found at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328) at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1360) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1118) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) at org.springframework.aop.framework.autoproxy.BeanFactoryAdvisorRetrievalHelper.findAdvisorBeans(BeanFactoryAdvisorRetrievalHelper.java:86) at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findCandidateAdvisors(AbstractAdvisorAutoProxyCreator.java:100) at org.springframework.aop.aspectj.autoproxy.AspectJAwareAdvisorAutoProxyCreator.shouldSkip(AspectJAwareAdvisorAutoProxyCreator.java:107) at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessBeforeInstantiation(AbstractAutoProxyCreator.java:278) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInstantiation(AbstractAutowireCapableBeanFactory.java:880) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.resolveBeforeInstantiation(AbstractAutowireCapableBeanFactory.java:852) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:446) ... 34 more Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'methodCacheInterceptor' defined in class path resource [spring/applicationContext_ehcache.xml]: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type '$Proxy4 implementing net.sf.ehcache.terracotta.InternalEhcache,net.sf.ehcache.store.StoreListener,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised' to required type 'net.sf.ehcache.Cache' for property 'cache'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [$Proxy4 implementing net.sf.ehcache.terracotta.InternalEhcache,net.sf.ehcache.store.StoreListener,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised] to required type [net.sf.ehcache.Cache] for property 'cache': no matching editors or conversion strategy found at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193) at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:322) ... 50 more Caused by: org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type '$Proxy4 implementing net.sf.ehcache.terracotta.InternalEhcache,net.sf.ehcache.store.StoreListener,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised' to required type 'net.sf.ehcache.Cache' for property 'cache'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [$Proxy4 implementing net.sf.ehcache.terracotta.InternalEhcache,net.sf.ehcache.store.StoreListener,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised] to required type [net.sf.ehcache.Cache] for property 'cache': no matching editors or conversion strategy found at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:485) at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:516) at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:510) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1406) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1365) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1118) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517) ... 56 more Caused by: java.lang.IllegalStateException: Cannot convert value of type [$Proxy4 implementing net.sf.ehcache.terracotta.InternalEhcache,net.sf.ehcache.store.StoreListener,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised] to required type [net.sf.ehcache.Cache] for property 'cache': no matching editors or conversion strategy found at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:241) at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:470) ... 62 more 2013-1-6 14:33:38 org.apache.catalina.core.StandardContext listenerStart 严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [applicationContext.xml]: BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'methodCachePointCut' defined in class path resource [spring/applicationContext_ehcache.xml]: Cannot resolve reference to bean 'methodCacheInterceptor' while setting bean property 'advice'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'methodCacheInterceptor' defined in class path resource [spring/applicationContext_ehcache.xml]: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type '$Proxy4 implementing net.sf.ehcache.terracotta.InternalEhcache,net.sf.ehcache.store.StoreListener,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised' to required type 'net.sf.ehcache.Cache' for property 'cache'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [$Proxy4 implementing net.sf.ehcache.terracotta.InternalEhcache,net.sf.ehcache.store.StoreListener,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised] to required type [net.sf.ehcache.Cache] for property 'cache': no matching editors or conversion strategy found at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:452) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464) at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:385) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:284) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3827) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4334) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525) at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:920) at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:883) at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492) at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1138) at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053) at org.apache.catalina.core.StandardHost.start(StandardHost.java:719) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443) at org.apache.catalina.core.StandardService.start(StandardService.java:516) at org.apache.catalina.core.StandardServer.start(StandardServer.java:710) at org.apache.catalina.startup.Catalina.start(Catalina.java:566) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413) Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'methodCachePointCut' defined in class path resource [spring/applicationContext_ehcache.xml]: Cannot resolve reference to bean 'methodCacheInterceptor' while setting bean property 'advice'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'methodCacheInterceptor' defined in class path resource [spring/applicationContext_ehcache.xml]: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type '$Proxy4 implementing net.sf.ehcache.terracotta.InternalEhcache,net.sf.ehcache.store.StoreListener,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised' to required type 'net.sf.ehcache.Cache' for property 'cache'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [$Proxy4 implementing net.sf.ehcache.terracotta.InternalEhcache,net.sf.ehcache.store.StoreListener,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised] to required type [net.sf.ehcache.Cache] for property 'cache': no matching editors or conversion strategy found at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328) at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1360) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1118) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) at org.springframework.aop.framework.autoproxy.BeanFactoryAdvisorRetrievalHelper.findAdvisorBeans(BeanFactoryAdvisorRetrievalHelper.java:86) at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findCandidateAdvisors(AbstractAdvisorAutoProxyCreator.java:100) at org.springframework.aop.aspectj.autoproxy.AspectJAwareAdvisorAutoProxyCreator.shouldSkip(AspectJAwareAdvisorAutoProxyCreator.java:107) at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessBeforeInstantiation(AbstractAutoProxyCreator.java:278) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInstantiation(AbstractAutowireCapableBeanFactory.java:880) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.resolveBeforeInstantiation(AbstractAutowireCapableBeanFactory.java:852) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:446) ... 34 more Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'methodCacheInterceptor' defined in class path resource [spring/applicationContext_ehcache.xml]: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type '$Proxy4 implementing net.sf.ehcache.terracotta.InternalEhcache,net.sf.ehcache.store.StoreListener,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised' to required type 'net.sf.ehcache.Cache' for property 'cache'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [$Proxy4 implementing net.sf.ehcache.terracotta.InternalEhcache,net.sf.ehcache.store.StoreListener,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised] to required type [net.sf.ehcache.Cache] for property 'cache': no matching editors or conversion strategy found at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193) at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:322) ... 50 more Caused by: org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type '$Proxy4 implementing net.sf.ehcache.terracotta.InternalEhcache,net.sf.ehcache.store.StoreListener,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised' to required type 'net.sf.ehcache.Cache' for property 'cache'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [$Proxy4 implementing net.sf.ehcache.terracotta.InternalEhcache,net.sf.ehcache.store.StoreListener,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised] to required type [net.sf.ehcache.Cache] for property 'cache': no matching editors or conversion strategy found at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:485) at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:516) at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:510) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1406) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1365) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1118) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517) ... 56 more Caused by: java.lang.IllegalStateException: Cannot convert value of type [$Proxy4 implementing net.sf.ehcache.terracotta.InternalEhcache,net.sf.ehcache.store.StoreListener,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised] to required type [net.sf.ehcache.Cache] for property 'cache': no matching editors or conversion strategy found at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:241) at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:470) ... 62 more 我试过删除一个切面的话项目是能够完全启动的, <!-- 配置一个简单的缓存工厂bean对象 --> <bean id="simpleCache" class="org.springframework.cache.ehcache.EhCacheFactoryBean"> <property name="cacheManager" ref="cacheManager" /> <!-- 使用缓存 关联ehcache.xml中的缓存配置 --> <property name="cacheName" value="mobileCache" /> </bean> <!-- 参与缓存的切入点对象 (切入点对象,确定何时何地调用拦截器) --> <bean id="methodCachePointCut" class="org.springframework.aop.support.RegexpMethodPointcutAdvisor"> <!-- 配置缓存aop切面 --> <property name="advice" ref="methodCacheInterceptor" /> <!-- 配置哪些方法参与缓存策略 --> <!-- .表示符合任何单一字元 ### +表示符合前一个字元一次或多次 ### *表示符合前一个字元零次或多次 ### \Escape任何Regular expression使用到的符号 --> <!-- .*表示前面的前缀(包括包名) 表示print方法--> <property name="patterns"> <list> <!-- <value>com.scxxs.dao.*get*</value> <value>com.scxxs.dao.*find*</value> <value>com.scxxs.dao.*query*</value> --> <value>.*find.*</value> </list> </property> </bean> 像上面这种配置有两个删除其中一个都没问题。我还测试过缓存起作用没,当我删除后面那个after切面后项目正常启动且缓存起作用,请教各位大虾为了我两个切面都存在的时候就要报错,报错信息就是上面那种,搞不懂啊!!!!
spring+ibatis 事务错误
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'studentdao' defined in URL [file:/E:/资料/apache-tomcat-6.0.29/webapps/firstibatis/WEB-INF/classes/spring/applicationContext-jdbc.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'driverClassName' of bean class [dao.impl.StudentDaoImpl]: Bean property 'driverClassName' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter? at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1427) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1132) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:522) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:607) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479) at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:383) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:283) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4135) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4630) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:546) at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1041) at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:964) at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:502) at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1277) at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:321) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053) at org.apache.catalina.core.StandardHost.start(StandardHost.java:785) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:445) at org.apache.catalina.core.StandardService.start(StandardService.java:519) at org.apache.catalina.core.StandardServer.start(StandardServer.java:710) xml配置文件如下: <bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="dataSource"/> </bean> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"> <property name="driverClassName" value="com.mysql.jdbc.Driver"/> <property name="url" value="jdbc:mysql://127.0.0.1/student"/> <property name="username" value="root"/> <property name="password" value="root"/> </bean> <!--配置哪些方法,什么情况下需要回滚--> <tx:advice id="serviceAdvice" transaction-manager="txManager"> <tx:attributes> <!--当代理的service层中的方法抛出异常的时候才回滚,必须加rollback-for参数--> <tx:method name="insert*" propagation="REQUIRED" rollback-for="Throwable"/> <tx:method name="del*" propagation="REQUIRED" rollback-for="Throwable"/> <tx:method name="update*" propagation="REQUIRED" rollback-for="Throwable"/> <!--除了上面标识的方法,其他方法全是只读方法 --> <tx:method name="*" read-only="true"/> </tx:attributes> </tx:advice> <!-- 配置哪些类的方法需要进行事务管理 --> <aop:config proxy-target-class="true"> <aop:pointcut id="servicePointcut" expression="execution(* dao.impl.*.*(..))"/> <aop:advisor pointcut-ref="servicePointcut" advice-ref="serviceAdvice"/> </aop:config> <bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean"> <property name="configLocation"><value>classpath:config/jdbc/sqlMapConfig.xml</value></property> </bean> <bean id="studentdao" class="dao.impl.StudentDaoImpl"> <property name="sqlMapClient" ref="sqlMapClient"></property> </bean> <bean id="studentmanager" class="manager.impl.StudentManagerImpl"> <property name="studentdao" ref="studentdao"></property> </bean> studentdaoimpl public class StudentDaoImpl extends SqlMapClientDaoSupport implements StudentDao{ @Override public List<Student> getAllStudent() { // TODO Auto-generated method stub return null; } @Override public Student getStudentById(String id) { // TODO Auto-generated method stub return null; } @Override public List<Object> select(String name) throws Exception { // TODO Auto-generated method stub return null; } @Override public List<Student> selects(Map map) throws Exception { // TODO Auto-generated method stub return null; } @Override public void tianjia(Map map) throws Exception { // TODO Auto-generated method stub } @Override public void update(Map map) throws Exception { // TODO Auto-generated method stub } }
微信小程序本地测试没问题,体验版没问题,审核时报错被驳回
## 问题描述: 之前给公司做了个小程序,上线之后没有问题,审核也通过了,近期有需求做了一些更改(改动不大),这是背景。 然后这次提交审核之后,被驳回了,原因是小程序无法正常使用,看了下审核反馈的截图,登录未成功,报错了。 我立马用体验版测试,因为体验版就是审核的代码,后台连接的服务器程序也是完全一致的,结果亮点来了,我体验版**完美运行** 后来又测试了本地版本,又用了各种方式测试了体验版本,都没有问题,再次提交审核,不出意外,又毙了。。 拉出审核人员登录时的后台日志: ``` ================================================================================================================================================================================================================================================ ==========================日志开始====================== ================================================================================================================================================================================================================================================ 开始计时:07:42:04.389 URI : /fleetif/fleet/loginFleet Controller : com.organ.controller.fleet.FleetLoginController Method : loginFleet Method Type : POST contentType : application/json Params : {"tel":"10001000","checkCode":"1234"} [DEBUG] 2019-12-09 19:42:04 AbstractMessageConverterMethodArgumentResolver.java DEBUG method:org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodArgumentResolver.readWithMessageConverters(AbstractMessageConverterMethodArgumentResolver.java:197) Read [class com.organ.entity.fleet.FleetUser] as "application/json;charset=UTF-8" with [org.springframework.http.converter.json.MappingJackson2HttpMessageConverter@47b74fce] [DEBUG] 2019-12-09 19:42:04 SqlSessionUtils.java DEBUG method:org.mybatis.spring.SqlSessionUtils.getSqlSession(SqlSessionUtils.java:109) Creating a new SqlSession [DEBUG] 2019-12-09 19:42:04 SqlSessionUtils.java DEBUG method:org.mybatis.spring.SqlSessionUtils.getSqlSession(SqlSessionUtils.java:145) SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@18c7d16e] was not registered for synchronization because synchronization is not active [DEBUG] 2019-12-09 19:42:04 DataSourceUtils.java DEBUG method:org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:110) Fetching JDBC Connection from DataSource [DEBUG] 2019-12-09 19:42:04 SpringManagedTransaction.java DEBUG method:org.mybatis.spring.transaction.SpringManagedTransaction.openConnection(SpringManagedTransaction.java:88) JDBC Connection [org.apache.commons.dbcp.PoolableConnection@22754112] will not be managed by Spring [DEBUG] 2019-12-09 19:42:04 BaseJdbcLogger.java DEBUG method:org.apache.ibatis.logging.jdbc.BaseJdbcLogger.debug(BaseJdbcLogger.java:139) ==> Preparing: SELECT id, user_name userName, tel, user_type userType, state, balance, balance_state balanceState, parent_id parentId, check_code checkCode, create_time createTime, is_del isDel, unit_price_0 unitPrice0, unit_price_10 unitPrice10 FROM `fleet_user` WHERE tel = ? AND is_del = ? [DEBUG] 2019-12-09 19:42:04 SQLErrorCodeSQLExceptionTranslator.java DEBUG method:org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:281) Unable to translate SQLException with Error code '0', will now try the fallback translator [DEBUG] 2019-12-09 19:42:04 SqlSessionUtils.java DEBUG method:org.mybatis.spring.SqlSessionUtils.closeSqlSession(SqlSessionUtils.java:173) Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@18c7d16e] [DEBUG] 2019-12-09 19:42:04 DataSourceUtils.java DEBUG method:org.springframework.jdbc.datasource.DataSourceUtils.doReleaseConnection(DataSourceUtils.java:329) Returning JDBC Connection to DataSource [DEBUG] 2019-12-09 19:42:04 DataSourceUtils.java DEBUG method:org.springframework.jdbc.datasource.DataSourceUtils.releaseConnection(DataSourceUtils.java:299) Could not close JDBC Connection java.sql.SQLException: Already closed. at org.apache.commons.dbcp.PoolableConnection.close(PoolableConnection.java:114) at org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.close(PoolingDataSource.java:191) at org.springframework.jdbc.datasource.DataSourceUtils.doCloseConnection(DataSourceUtils.java:343) at org.springframework.jdbc.datasource.DataSourceUtils.doReleaseConnection(DataSourceUtils.java:330) at org.springframework.jdbc.datasource.DataSourceUtils.releaseConnection(DataSourceUtils.java:296) at org.mybatis.spring.transaction.SpringManagedTransaction.close(SpringManagedTransaction.java:125) at org.apache.ibatis.executor.BaseExecutor.close(BaseExecutor.java:83) at org.apache.ibatis.executor.CachingExecutor.close(CachingExecutor.java:61) at org.apache.ibatis.session.defaults.DefaultSqlSession.close(DefaultSqlSession.java:210) at org.mybatis.spring.SqlSessionUtils.closeSqlSession(SqlSessionUtils.java:175) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:375) at com.sun.proxy.$Proxy51.selectOne(Unknown Source) at org.mybatis.spring.SqlSessionTemplate.selectOne(SqlSessionTemplate.java:163) at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:68) at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:52) at com.sun.proxy.$Proxy59.findFleetUser(Unknown Source) at com.organ.service.fleet.FleetUserService.findFleetUser(FleetUserService.java:39) at com.organ.service.fleet.FleetUserService$$FastClassBySpringCGLIB$$888fc21f.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:669) at com.organ.service.fleet.FleetUserService$$EnhancerBySpringCGLIB$$726af94b.findFleetUser(<generated>) at com.organ.controller.fleet.FleetLoginController.loginFleet(FleetLoginController.java:104) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:133) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:97) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:967) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:901) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970) at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872) at javax.servlet.http.HttpServlet.service(HttpServlet.java:660) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846) at javax.servlet.http.HttpServlet.service(HttpServlet.java:741) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at com.organ.filter.PostRequestFilter.doFilter(PostRequestFilter.java:35) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.apache.logging.log4j.core.web.Log4jServletFilter.doFilter(Log4jServletFilter.java:66) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:493) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81) at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:660) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343) at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:798) at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:808) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1498) at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:748) [DEBUG] 2019-12-09 19:42:04 AbstractMessageConverterMethodProcessor.java DEBUG method:org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodProcessor.writeWithMessageConverters(AbstractMessageConverterMethodProcessor.java:234) Written [com.organ.controller.base.ResultData@13c8038d] as "application/json" using [org.springframework.http.converter.json.MappingJackson2HttpMessageConverter@47b74fce] [DEBUG] 2019-12-09 19:42:04 LogInterceptor.java DEBUG method:com.organ.interceptor.LogInterceptor.postHandle(LogInterceptor.java:118) --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- CostTime : 8ms --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- [DEBUG] 2019-12-09 19:42:04 DispatcherServlet.java DEBUG method:org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1048) Null ModelAndView returned to DispatcherServlet with name 'springDispatcherServlet': assuming HandlerAdapter completed request handling [DEBUG] 2019-12-09 19:42:04 LogInterceptor.java DEBUG method:com.organ.interceptor.LogInterceptor.afterCompletion(LogInterceptor.java:142) 计时结束:07:42:04.397 耗时:8 URI:/fleetif/fleet/loginFleet [DEBUG] 2019-12-09 19:42:04 LogInterceptor.java DEBUG method:com.organ.interceptor.LogInterceptor.afterCompletion(LogInterceptor.java:149) --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- [DEBUG] 2019-12-09 19:42:04 FrameworkServlet.java DEBUG method:org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1000) Successfully completed request [DEBUG] 2019-12-09 19:42:33 PostRequestFilter.java DEBUG method:com.organ.filter.PostRequestFilter.doFilter(PostRequestFilter.java:27) ------------------------PostRequestFilter doFilter execute!!! [DEBUG] 2019-12-09 19:42:33 DispatcherServlet.java DEBUG method:org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:869) DispatcherServlet with name 'springDispatcherServlet' processing POST request for [/fleetif/fleet/smsCode] [DEBUG] 2019-12-09 19:42:33 AbstractHandlerMethodMapping.java DEBUG method:org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.getHandlerInternal(AbstractHandlerMethodMapping.java:310) Looking up handler method for path /fleet/smsCode [DEBUG] 2019-12-09 19:42:33 AbstractHandlerMethodMapping.java DEBUG method:org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.getHandlerInternal(AbstractHandlerMethodMapping.java:317) Returning handler method [public java.lang.Object com.organ.controller.fleet.FleetLoginController.smsCode(javax.servlet.http.HttpServletRequest,java.util.Map<java.lang.String, java.lang.String>)] [DEBUG] 2019-12-09 19:42:33 AbstractBeanFactory.java DEBUG method:org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:251) Returning cached instance of singleton bean 'fleetLoginController' [DEBUG] 2019-12-09 19:42:33 LogInterceptor.java DEBUG method:com.organ.interceptor.LogInterceptor.preHandle(LogInterceptor.java:90) ``` 可以看到数据库报了个错,但是这个错什么原因目前查不出来,而且我们无法复现,我们测试一切正常,只要审核人员登录就会报这个错误。 有没有大神指导一下,现在头都大了。。。
myBatis中的莫名其妙的java.lang.NullPointerException,求指教
xml: <sql id="querywheresrlnodate"> <!-- ognl访问静态方法的表达式 为@class@method(args),以下为调用Ognl.isNotEmpty()方法,还有其它方法如isNotBlank()可以使用,具体请查看Ognl类 --> <where> <if test="@Ognl@isNotEmpty(h_srlno)"> AND SRLNO = '${h_srlno}' </if> <if test="@Ognl@isNotEmpty(h_date)"> AND URGEDATE = '${h_date}' </if> </where> </sql> <select id="findBySrlnoDate" parameterType="java.util.HashMap" resultType="com.mf.cntrtmng.entity.BsnsOverdueUrge"> SELECT <include refid="selectId" /> FROM bsns_overdue_urge <include refid="querywheresrlnodate"/> </select> DAO: public BsnsOverdueUrge findBySrlnoDate(Map params) throws DataAccessException; Serviceimpl: public boolean exist(Map params) { System.out.println("=====搜索出来的"); System.out.println(params); if(bsnsOverdueUrgeDao.findBySrlnoDate(params)==null) return true; else return false; } 错误日志: =====搜索出来的 {h_srlno=JH201505281535107052, h_date=20150601} 2015-06-01 15:19:42,922 DEBUG [http-bio-8080-exec-3] (JakartaCommonsLoggingImpl.java:46) - Creating a new SqlSession 2015-06-01 15:19:42,922 DEBUG [http-bio-8080-exec-3] (JakartaCommonsLoggingImpl.java:46) - Registering transaction synchronization for SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@6d41567b] 2015-06-01 15:19:42,924 DEBUG [http-bio-8080-exec-3] (JakartaCommonsLoggingImpl.java:46) - JDBC Connection [jdbc:mysql://localhost:3306/microfinance?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&autoReconnect=true, UserName=root@localhost, MySQL-AB JDBC Driver] will be managed by Spring 2015-06-01 15:19:42,925 DEBUG [http-bio-8080-exec-3] (JakartaCommonsLoggingImpl.java:46) - ooo Using Connection [jdbc:mysql://localhost:3306/microfinance?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&autoReconnect=true, UserName=root@localhost, MySQL-AB JDBC Driver] 2015-06-01 15:19:42,928 DEBUG [http-bio-8080-exec-3] (JakartaCommonsLoggingImpl.java:46) - ==> Preparing: select count(1) from (SELECT NO, SRLNO, CLNTNO, URGEID, URGENAME, URGEDATE FROM bsns_overdue_urge WHERE SRLNO = 'JH201505281535107052' AND URGEDATE = '20150601') tmp_count 2015-06-01 15:19:42,929 DEBUG [http-bio-8080-exec-3] (JakartaCommonsLoggingImpl.java:46) - ==> Parameters: 2015-06-01 15:19:42,930 DEBUG [http-bio-8080-exec-3] (JakartaCommonsLoggingImpl.java:46) - Releasing transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@6d41567b] 2015-06-01 15:19:42,930 DEBUG [http-bio-8080-exec-3] (AbstractPlatformTransactionManager.java:843) - Initiating transaction rollback 2015-06-01 15:19:42,931 DEBUG [http-bio-8080-exec-3] (DataSourceTransactionManager.java:279) - Rolling back JDBC transaction on Connection [jdbc:mysql://localhost:3306/microfinance?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&autoReconnect=true, UserName=root@localhost, MySQL-AB JDBC Driver] 2015-06-01 15:19:42,932 DEBUG [http-bio-8080-exec-3] (JakartaCommonsLoggingImpl.java:46) - Transaction synchronization rolling back SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@6d41567b] 2015-06-01 15:19:42,932 DEBUG [http-bio-8080-exec-3] (JakartaCommonsLoggingImpl.java:46) - Transaction synchronization closing SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@6d41567b] 2015-06-01 15:19:42,933 DEBUG [http-bio-8080-exec-3] (DataSourceTransactionManager.java:322) - Releasing JDBC Connection [jdbc:mysql://localhost:3306/microfinance?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&autoReconnect=true, UserName=root@localhost, MySQL-AB JDBC Driver] after transaction org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. Cause: java.lang.NullPointerException ### The error may exist in file [E:\SpringSource\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\microfinance20150203\WEB-INF\classes\com\mf\cntrtmng\entity\mapper\bsnsoverdueurge-mapper.xml] ### The error may involve com.mf.cntrtmng.dao.BsnsOverdueUrgeDao.findBySrlnoDate-Inline ### The error occurred while setting parameters ### Cause: java.lang.NullPointerException 2015-06-01 15:19:42,933 DEBUG [http-bio-8080-exec-3] (DataSourceUtils.java:332) - Returning JDBC Connection to DataSource at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:73) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:365) at com.sun.proxy.$Proxy11.selectOne(Unknown Source) at org.mybatis.spring.SqlSessionTemplate.selectOne(SqlSessionTemplate.java:160) at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:63) at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:43) at com.sun.proxy.$Proxy114.findBySrlnoDate(Unknown Source) at com.mf.cntrtmng.service.impl.BsnsOverdueUrgeServiceImpl.exist(BsnsOverdueUrgeServiceImpl.java:128) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:319) at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202) at com.sun.proxy.$Proxy115.exist(Unknown Source) at com.mf.aftrmng.controller.LoanWarnController.showUrgeInfo(LoanWarnController.java:310) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:213) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:126) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:96) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:617) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:578) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778) at javax.servlet.http.HttpServlet.service(HttpServlet.java:620) at javax.servlet.http.HttpServlet.service(HttpServlet.java:727) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at com.mf.interceptor.HeadInterceptor.doFilter(HeadInterceptor.java:43) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1040) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:315) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918) at java.lang.Thread.run(Thread.java:662) 从日志里面打印的SQL,可以在数据库中搜索,怎么返回值变成了count(),我不是在xml中配置的返回值类型为一个对象类型么“resultType="com.mf.cntrtmng.entity.BsnsOverdueUrge"?”然后包了莫名其妙的空指针错误,求大神帮忙看看,小弟感激不尽~~
Java中使用quartz定时器:定时处理类中却不能注入jdbc的接口类,报空指针
定时器配置文件: <?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:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:mvc="http://www.springframework.org/schema/mvc" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd"> <!-- 使用MethodInvokingJobDetailFactoryBean,任务类可以不实现Job接口,通过targetMethod指定调用方法--> <bean id="cathodicInspectTaskJob" class="com.geok.gas.CathodicInspectTimer"/> <bean id="cathodicInspectJob" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean"> <!--false表示等上一个任务执行完后再开启新的任务--> <property name="concurrent" value="false"/> <property name="targetObject"> <ref bean="cathodicInspectTaskJob"/> </property> <property name="targetMethod"> <value>run</value> </property> </bean> <!-- 调度触发器 --> <bean id="cathodicInspectTrigger" class="org.springframework.scheduling.quartz.CronTriggerFactoryBean"> <property name="jobDetail"> <ref bean="cathodicInspectJob" /> </property> <property name="cronExpression"> <value> 0 39 09 * * ? </value> </property> </bean> <!-- 调度工厂 --> <bean id="scheduler2" class="org.springframework.scheduling.quartz.SchedulerFactoryBean"> <property name="triggers"> <list> <ref bean="cathodicInspectTrigger"/> </list> </property> </bean> </beans> ``` ``` 处理类:CathodicInspectTimer package com.geok.gas; import java.util.HashMap; import java.util.List; import java.util.Map; import org.springframework.beans.factory.annotation.Autowired; import com.geok.core.common.exception.GeoException; import com.geok.core.common.util.DateTime; import com.geok.core.common.util.PIMConfig; import com.geok.core.jdbc.def.IJdbcDao; import com.geok.system.common.OrgUtil; import com.project.web.util.UUID; public class CathodicInspectTimer { @Autowired private IJdbcDao jdbcDao; private String table_name =PIMConfig.DATABASE_OWNERBY+"pi";//阴保检测工作表(要插入数据的表) private String PC_USER_MENU =PIMConfig.DATABASE_OWNERBY+"PC_USER_MENU";//用户菜单表 private String PC_USER =PIMConfig.DATABASE_OWNERBY+"PC_USER";//系统用户表 String time=DateTime.getDateTime();//系统日期和时间,格式: yyyy-MM-dd HH:mm:ss String yearMonth=DateTime.getYearMonth();//系统当前年月,格式: yyyy-MM public void run(){ System.out.println("阴保作业任务开始 running!"); insertData(); } @SuppressWarnings("rawtypes") private void insertData(){ try { long start = System.currentTimeMillis();//运行起始时间 List personList = this.getPersonList();//获取系统用户数据 Map<String,Map> personMap = new HashMap<String, Map>();//以数据的id为key,数据本身为map的map对象 for(int i=0;i<personList.size();i++){ Map map = (Map)personList.get(i); personMap.put(map.get("EVENTID").toString(), map); } List list=this.getPersonData("010202020108");//阴保测试作业有新增权限的数据集合 String sqlinsert = "INSERT INTO "+table_name+" (EVENTID, DEPARTMENTID, CREATEID, CREATENAME, CREATEDATE, MODIFYID, MODIFYNAME, MODIFYDATE,WORKNAME)";//要插入的列 OrgUtil util = new OrgUtil();//部门工具类 for(int j=0;j<list.size();j++){//循环拼接sql语句来添加数据 Map map1 = (Map)list.get(j); String USEREVENTID = (String)map1.get("USEREVENTID");//获取有权限的用户id Map map2 = personMap.get(USEREVENTID);//通过用户id获取该用户对象 sqlinsert += " select '"+UUID.getUUID()+"','"+map2.get("ORGID")+"','" +map2.get("EVENTID")+"','"+map2.get("NAME")+"','"+time+"','" +map2.get("EVENTID")+"','"+map2.get("NAME")+"','"+time+"','" +yearMonth.replace("-", "年")+"月"+util.getOrgName(map2.get("ORGID").toString())+"阴保检测作业'" +" FROM DUAL UNION "; } if(sqlinsert.indexOf("UNION")>0){//判断数据集合中存在数据 sqlinsert = sqlinsert.substring(0, sqlinsert.length()-6); jdbcDao.insertOrUpdate(sqlinsert); } long end = System.currentTimeMillis();//运行结束时间 System.out.println("插入:"+list.size()+"条 "+ (end - start) + "毫秒"); System.out.println("阴保作业任务结束 running!"); } catch (Exception e) { e.printStackTrace(); } } private List getPersonData(String menuId) throws GeoException{ String sql = "SELECT * FROM "+PC_USER_MENU+" T WHERE T.MENUID = '"+menuId+"'"; return jdbcDao.queryForMapList(sql); } /** * 获取系统用户数据 * @return * @throws GeoException */ private List getPersonList() throws GeoException{ String sql = "SELECT T.EVENTID,T.NAME,T.ORGID FROM "+PC_USER+" T WHERE T.ACTIVE = 1"; return jdbcDao.queryForMapList(sql); } } ``` ```
Spring的ProxyFactory的方法——addInterceptor()
UserDao类: package com.sunyan.dao; import java.util.HashMap; import java.util.Map; import java.util.Set; public class UserDao { private Map<String,String> map = new HashMap<String,String>(); public UserDao(){ map.put("admin", "security"); map.put("test", "123"); } public void create(String username, String password){ if(map.get(username)!=null) throw new RuntimeException("User exist"); map.put(username, password); } public void login(String username,String password){ String pw = map.get(username); if(pw==null||!pw.equals(password)) throw new RuntimeException("Login failed"); } public void print(){ System.out.println("User list:"); Set<String> keySet = (Set) map.keySet(); for(String key : keySet) System.out.println(key); } } UserService接口: package com.sunyan.service; public interface UserService { void create(String username,String password); void login(String username,String password); } UserServiceImpl类: package com.sunyan.service.impl; import com.sunyan.dao.UserDao; import com.sunyan.service.UserService; public class UserServiceImpl implements UserService{ private UserDao userDao; public void setUserDao(UserDao userDao) { this.userDao = userDao; } @Override public void create(String username, String password) { userDao.create(username, password); } @Override public void login(String username, String password) { userDao.login(username, password); } } AopProxyFactory类: package com.sunyan.proxy; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; import java.lang.reflect.Proxy; import org.springframework.aop.MethodBeforeAdvice; public class AopProxyFactory { public static Object createProxy(final Object target,final MethodBeforeAdvice methodBeforeAdvice) { return Proxy.newProxyInstance(target.getClass().getClassLoader(),target.getClass().getInterfaces(), new InvocationHandler() { @Override public Object invoke(Object proxy, Method method,Object[] args) throws Throwable { //首先调用切面的before方法 methodBeforeAdvice.before(method, args, target); //然后调用实际对象的方法 return method.invoke(target, args); } }); } } 测试类: package com.sunyan.test; import java.lang.reflect.Method; import org.springframework.aop.MethodBeforeAdvice; import org.springframework.aop.framework.ProxyFactory; import com.sunyan.dao.UserDao; import com.sunyan.proxy.AopProxyFactory; import com.sunyan.service.UserService; import com.sunyan.service.impl.UserServiceImpl; public class DynamicProxyTest { public static void main(String[] args) { UserDao userDao = new UserDao(); UserServiceImpl target = new UserServiceImpl(); target.setUserDao(userDao); //创建日志记录切面 MethodBeforeAdvice log = new MethodBeforeAdvice(){ @Override public void before(Method m, Object[] args, Object target) throws Throwable { System.out.println("call method: "+ m.getName()); } }; /*//创建代理类 UserService userService = (UserService) AopProxyFactory.createProxy(target, log); //调用代理类的方法 userService.create("aop", "password"); userService.login("aop", "password"); userDao.print();*/ //我想使用的是Spring的ProxyFactory类,可是addInterceptor方法报错,说没有此方法。 ProxyFactory factory = new ProxyFactory(target); factory.addInterceptor(log); UserService userService = (UserService) factory.getProxy(); userService.create("aop", "password"); userService.login("aop", "password"); userDao.print(); } } 在测试类中的:factory.addInterceptor(log);出错,报说没有此方法,为什么?
使用Spring测试类测试,抛出HibernateException异常
我在开发中使用SpringTest测试机制进行服务层的单元测试,结果单元测试在执行初始化方法时就抛出异常,错误如下 [code="java"]java.lang.IllegalStateException: Failed to load ApplicationContext ... ... Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dictionaryManager': Invocation of init method failed; nested exception is org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here ... ... Caused by: org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here at org.springframework.orm.hibernate3.SpringSessionContext.currentSession(SpringSessionContext.java:63) at org.hibernate.impl.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:685) at com.lily.dap.dao.hibernate.HibernateDao.getSession(HibernateDao.java:73) at com.lily.dap.dao.hibernate.HibernateDao.createQuery(HibernateDao.java:432) at com.lily.dap.dao.hibernate.HibernateDao.query(HibernateDao.java:152) at com.lily.dap.dao.hibernate.HibernateDao.query(HibernateDao.java:113) at com.lily.dap.service.common.impl.DictionaryManagerImpl.init(DictionaryManagerImpl.java:63) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:592) at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:340) at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:293) at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:130) ... 39 more[/code] 单元测试类继承了Spring的AbstractTransactionalJUnit4SpringContextTests类,然后测试中使用的Spring配置如下: applicationContext-dao.xml [code="java"]<?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:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd" default-lazy-init="true"> <description>Spring DAO 配置文件</description> <bean id="dao" class="com.lily.dap.dao.hibernate.HibernateDao"> <property name="sessionFactory" ref="sessionFactory"/> <property name="batchSize" value="20"/> </bean> <!-- Hibernate配置 --> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <property name="namingStrategy"> <bean class="org.hibernate.cfg.ImprovedNamingStrategy" /> </property> <property name="hibernateProperties"> <value> hibernate.dialect=${hibernate.dialect} hibernate.query.substitutions=true 'Y', false 'N' hibernate.show_sql=${hibernate.show_sql} hibernate.format_sql=true hibernate.cache.use_second_level_cache=true hibernate.cache.provider_class=org.hibernate.cache.EhCacheProvider hibernate.hbm2ddl.auto=none </value> </property> <property name="packagesToScan" value="com.lily.dap.entity" /> </bean> <!-- 事务管理器配置,单数据源事务 --> <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory" /> </bean> <!-- 使用annotation定义事务 --> <tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true" /> </beans>[/code] DictionaryManagerTest-context.xml [code="java"]<?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:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"> <aop:config> <aop:advisor id="managerTx" advice-ref="txAdvice" pointcut="execution(* com.lily.dap.service..*Manager.*(..))"/> </aop:config> <context:annotation-config/> <!-- Enable @Transactional support --> <tx:annotation-driven/> <!-- Enable @AspectJ support --> <aop:aspectj-autoproxy/> <tx:advice id="txAdvice"> <tx:attributes> <tx:method name="get*" read-only="true" no-rollback-for="com.lily.dap.service.core.exception.DataNotExistException"/> <tx:method name="count*" read-only="true" no-rollback-for="com.lily.dap.service.core.exception.DataNotExistException"/> <tx:method name="*" no-rollback-for="com.lily.dap.service.core.exception.DataNotExistException"/> </tx:attributes> </tx:advice> <bean class="com.lily.dap.service.SpringContextHolder" lazy-init="false"/> <bean id= "manager" class="com.lily.dap.service.core.ManagerImpl"/> <bean id= "dictionaryManager" class="com.lily.dap.service.common.impl.DictionaryManagerImpl"/> </beans>[/code] DictionaryManagerImpl代码大体如下: [code="java"]@Service("dictionaryManager") public class DictionaryManagerImpl extends BaseManager implements DictionaryManager { /** * 存放字典使用实体集合的Map,其中key对应那个字典目录,value为这个字典目录有那些实体对象的那个字段使用着 */ private Map<String, List<DictAccess>> dictionaryAccessMap = new HashMap<String, List<DictAccess>>(); @PostConstruct public void init() { //读取字典使用实体数据至dictionaryAccessMap,以供在执行删除字典数据时判断数据是否被使用的依据 List<DictAccess> list = dao.query(DictAccess.class, null); for (DictAccess dictAccess : list) { String catalogCode = dictAccess.getCatalogCode(); List<DictAccess> dictAccessList = dictionaryAccessMap.get(catalogCode); if (dictAccessList == null) { dictAccessList = new ArrayList<DictAccess>(); dictionaryAccessMap.put(catalogCode, dictAccessList); } dictAccessList.add(dictAccess); } } ... ... [/code]
spring-mvc和mybatis整合DruidDataSource配置连接池报错
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dynamicDatasourceAspect' defined in file [D:\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\dm_job\WEB-INF\classes\com\creditease\job\aop\DynamicDatasourceAspect.class]: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'com.alibaba.druid.pool.DruidDataSource' to required type 'org.aspectj.lang.JoinPoint' for property 'dbmsDataSource'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [com.alibaba.druid.pool.DruidDataSource] to required type [org.aspectj.lang.JoinPoint] for property 'dbmsDataSource': no matching editors or conversion strategy found at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:547) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) at org.springframework.aop.aspectj.annotation.BeanFactoryAspectInstanceFactory.getAspectInstance(BeanFactoryAspectInstanceFactory.java:77) at org.springframework.aop.aspectj.annotation.LazySingletonAspectInstanceFactoryDecorator.getAspectInstance(LazySingletonAspectInstanceFactoryDecorator.java:50) at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:621) at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:603) at org.springframework.aop.aspectj.AspectJMethodBeforeAdvice.before(AspectJMethodBeforeAdvice.java:40) at org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:51) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:653) at com.creditease.job.service.impl.CityServiceImpl$$EnhancerBySpringCGLIB$$23f19862.getAllCityCodeAndName(<generated>) at com.creditease.job.base.InitDataListener.contextInitialized(InitDataListener.java:48) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4994) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5492) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1575) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1565) at java.util.concurrent.FutureTask.run(FutureTask.java:262) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:745) Caused by: org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'com.alibaba.druid.pool.DruidDataSource' to required type 'org.aspectj.lang.JoinPoint' for property 'dbmsDataSource'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [com.alibaba.druid.pool.DruidDataSource] to required type [org.aspectj.lang.JoinPoint] for property 'dbmsDataSource': no matching editors or conversion strategy found at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:476) at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:512) at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:506) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1523) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1482) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1222) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537) ... 26 more Caused by: java.lang.IllegalStateException: Cannot convert value of type [com.alibaba.druid.pool.DruidDataSource] to required type [org.aspectj.lang.JoinPoint] for property 'dbmsDataSource': no matching editors or conversion strategy found at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:287) at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:461) * ... 32 more 配置文件如下: <!-- 基础数据源配置 --> <bean id="baseDataSource" class="com.alibaba.druid.pool.DruidDataSource" destroy-method="close"> <!-- 配置初始化大小、最小、最大 --> <property name="initialSize" value="10" /> <property name="minIdle" value="10" /> <property name="maxActive" value="50" /> <!-- 配置获取连接等待超时的时间 --> <property name="maxWait" value="60000" /> <!-- 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 --> <property name="timeBetweenEvictionRunsMillis" value="60000" /> <!-- 配置一个连接在池中最小生存的时间,单位是毫秒 --> <property name="minEvictableIdleTimeMillis" value="300000" /> <property name="validationQuery" value="SELECT * FROM CREDIT_CHANNEL LIMT 1" /> <property name="testWhileIdle" value="true" /> <property name="testOnBorrow" value="false" /> <property name="testOnReturn" value="false" /> <!-- 打开PSCache,并且指定每个连接上PSCache的大小 --> <property name="poolPreparedStatements" value="true" /> <property name="maxPoolPreparedStatementPerConnectionSize" value="20" /> <!-- 配置监控统计拦截的filters --> <property name="filters" value="wall,stat" /> </bean> <!-- kls数据源 --> <bean id="klsDataSource" parent="baseDataSource"> <!-- 基本属性 url、user、password --> <property name="url" value="${kls.jdbc.url}" /> <property name="username" value="${kls.jdbc.username}" /> <property name="password" value="${kls.jdbc.password}" /> </bean> <!-- dbms数据源 --> <bean id="dbmsDataSource" parent="baseDataSource"> <!-- 基本属性 url、user、password --> <property name="url" value="${dbms.jdbc.url}" /> <property name="username" value="${dbms.jdbc.username}" /> <property name="password" value="${dbms.jdbc.password}" /> </bean> <!-- 设置spring 配置文件的配置多数源映射关系 --> <bean id="dataSource" class="com.creditease.job.datasource.DynamicDataSource"> <property name="targetDataSources"> <map> <entry value-ref="klsDataSource" key="kls"></entry> <entry value-ref="dbmsDataSource" key="dbms"></entry> </map> </property> <property name="defaultTargetDataSource" ref="klsDataSource" /> </bean> <bean id="dataSourceProxy" class="org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy"> <property name="targetDataSource" ref="dataSource" /> </bean> <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate"> <constructor-arg ref="dataSourceProxy" /> </bean> <!--事务管理器配置 --> <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="dataSourceProxy" /> </bean> <tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true"/> <tx:advice id="txAdvice" transaction-manager="transactionManager"> <tx:attributes> <tx:method name="*" propagation="REQUIRED" /> </tx:attributes> </tx:advice> <bean class="com.creditease.job.util.SpringUtils" /> <!-- 数据库工厂 --> <!-- mySqlSessionFactory配置 --> <bean id="mySqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <property name="configLocation" value="classpath:mybatis-config.xml" /> </bean> ![图片说明](https://img-ask.csdn.net/upload/201605/16/1463363631_18856.png)
spring mvc4.1+Websocket 链接时报错!
信息: Initializing Spring FrameworkServlet 'springmvc' WebSocketConfig new systemWebSocketHandler Before Handshake After Handshake 一月 19, 2017 3:41:06 下午 org.apache.catalina.core.StandardWrapperValve invoke 严重: Servlet.service() for servlet [springmvc] in context with path [/main] threw exception [Request processing failed; nested exception is org.springframework.web.socket.server.HandshakeFailureException: Uncaught failure for request http://localhost:8080/main/webSocketServer; nested exception is java.lang.NoSuchMethodError: org.apache.tomcat.websocket.server.WsServerContainer.doUpgrade(Ljavax/servlet/http/HttpServletRequest;Ljavax/servlet/http/HttpServletResponse;Ljavax/websocket/server/ServerEndpointConfig;Ljava/util/Map;)V] with root cause java.lang.NoSuchMethodError: org.apache.tomcat.websocket.server.WsServerContainer.doUpgrade(Ljavax/servlet/http/HttpServletRequest;Ljavax/servlet/http/HttpServletResponse;Ljavax/websocket/server/ServerEndpointConfig;Ljava/util/Map;)V at org.springframework.web.socket.server.standard.TomcatRequestUpgradeStrategy.upgradeInternal(TomcatRequestUpgradeStrategy.java:72) at org.springframework.web.socket.server.standard.AbstractStandardUpgradeStrategy.upgrade(AbstractStandardUpgradeStrategy.java:118) at org.springframework.web.socket.server.support.DefaultHandshakeHandler.doHandshake(DefaultHandshakeHandler.java:215) at org.springframework.web.socket.server.support.WebSocketHttpRequestHandler.handleRequest(WebSocketHttpRequestHandler.java:120) at org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter.handle(HttpRequestHandlerAdapter.java:51) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:943) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:877) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:961) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:852) at javax.servlet.http.HttpServlet.service(HttpServlet.java:621) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837) at javax.servlet.http.HttpServlet.service(HttpServlet.java:728) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:112) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:223) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:107) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:504) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:75) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:934) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:90) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:494) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1009) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:632) at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:223) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1592) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1550) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) 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>com.scrx.ymg</groupId> <artifactId>main</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>war</packaging> <name>YMG</name> <description/> <properties> <webVersion>3.1</webVersion> <hibernate-version>5.1.0.Final</hibernate-version> <hibernate-validator-version>5.2.4.Final</hibernate-validator-version> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <dependencies> <dependency> <groupId>javax</groupId> <artifactId>javaee-api</artifactId> <version>7.0</version> </dependency> <dependency> <groupId>org.glassfish.web</groupId> <artifactId>javax.servlet.jsp.jstl</artifactId> <version>1.2.2</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-aop</artifactId> <version>4.1.0.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-aspects</artifactId> <version>4.1.0.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-beans</artifactId> <version>4.1.0.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>4.1.0.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context-support</artifactId> <version>4.1.0.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-expression</artifactId> <version>4.1.0.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-instrument</artifactId> <version>4.1.0.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-instrument-tomcat</artifactId> <version>4.1.0.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> <version>4.3.0.RELEASE</version> </dependency> <dependency> <groupId>aopalliance</groupId> <artifactId>aopalliance</artifactId> <version>1.0</version> </dependency> <dependency> <groupId>commons-pool</groupId> <artifactId>commons-pool</artifactId> <version>1.6</version> </dependency> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.17</version> </dependency> <dependency> <groupId>org.aspectj</groupId> <artifactId>aspectjweaver</artifactId> <version>1.8.2</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> <version>4.1.0.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>4.1.0.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc-portlet</artifactId> <version>4.1.0.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-jms</artifactId> <version>4.1.0.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-oxm</artifactId> <version>4.1.0.RELEASE</version> </dependency> <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-web</artifactId> <version>3.2.5.RELEASE</version> </dependency> <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-core</artifactId> <version>3.2.5.RELEASE</version> </dependency> <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-acl</artifactId> <version>3.2.5.RELEASE</version> </dependency> <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-aspects</artifactId> <version>3.2.5.RELEASE</version> </dependency> <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-cas</artifactId> <version>3.2.5.RELEASE</version> </dependency> <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-config</artifactId> <version>3.2.5.RELEASE</version> </dependency> <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-crypto</artifactId> <version>3.2.5.RELEASE</version> </dependency> <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-ldap</artifactId> <version>3.2.5.RELEASE</version> </dependency> <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-openid</artifactId> <version>3.2.5.RELEASE</version> </dependency> <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-remoting</artifactId> <version>3.2.5.RELEASE</version> </dependency> <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-taglibs</artifactId> <version>3.2.5.RELEASE</version> </dependency> <dependency> <groupId>org.springframework.webflow</groupId> <artifactId>spring-webflow</artifactId> <version>2.4.0.RELEASE</version> </dependency> <dependency> <groupId>org.springframework.webflow</groupId> <artifactId>spring-binding</artifactId> <version>2.4.0.RELEASE</version> </dependency> <dependency> <groupId>org.springframework.webflow</groupId> <artifactId>spring-js</artifactId> <version>2.4.0.RELEASE</version> </dependency> <dependency> <groupId>org.springframework.webflow</groupId> <artifactId>spring-js-resources</artifactId> <version>2.4.0.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-orm</artifactId> <version>4.3.0.RELEASE</version> </dependency> <dependency> <groupId>opensymphony</groupId> <artifactId>ognl</artifactId> <version>2.6.11</version> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-core</artifactId> <version>${hibernate-version}</version> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-entitymanager</artifactId> <version>${hibernate-version}</version> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-jpamodelgen</artifactId> <version>${hibernate-version}</version> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-validator</artifactId> <version>${hibernate-validator-version}</version> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-validator-annotation-processor</artifactId> <version>${hibernate-validator-version}</version> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-validator-cdi</artifactId> <version>${hibernate-validator-version}</version> </dependency> <dependency> <groupId>commons-dbcp</groupId> <artifactId>commons-dbcp</artifactId> <version>1.4</version> </dependency> <dependency> <groupId>commons-pool</groupId> <artifactId>commons-pool</artifactId> <version>1.6</version> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.1.40</version> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> <version>2.5</version> <scope>provided</scope> </dependency> <dependency> <groupId>javax.servlet.jsp</groupId> <artifactId>jsp-api</artifactId> <version>2.1</version> <scope>provided</scope> </dependency> <dependency> <groupId>javax.el</groupId> <artifactId>javax.el-api</artifactId> <version>2.2.4</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>1.6.1</version> </dependency> <dependency> <groupId>org.glassfish.web</groupId> <artifactId>javax.el</artifactId> <version>2.2.4</version> </dependency> <dependency> <groupId>xml-apis</groupId> <artifactId>xml-apis</artifactId> <version>1.4.01</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-core</artifactId> <version>2.3.0</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> <version>2.3.0</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-websocket</artifactId> <version>4.0.1.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-messaging</artifactId> <version>4.0.1.RELEASE</version> </dependency> </dependencies> <build> <plugins> <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>2.3.2</version> <configuration> <source>1.7</source> <target>1.7</target> </configuration> </plugin> <plugin> <artifactId>maven-war-plugin</artifactId> <version>2.6</version> <configuration> <failOnMissingWebXml>false</failOnMissingWebXml> </configuration> </plugin> </plugins> </build> </project>
Java学习的正确打开方式
在博主认为,对于入门级学习java的最佳学习方法莫过于视频+博客+书籍+总结,前三者博主将淋漓尽致地挥毫于这篇博客文章中,至于总结在于个人,实际上越到后面你会发现学习的最好方式就是阅读参考官方文档其次就是国内的书籍,博客次之,这又是一个层次了,这里暂时不提后面再谈。博主将为各位入门java保驾护航,各位只管冲鸭!!!上天是公平的,只要不辜负时间,时间自然不会辜负你。 何谓学习?博主所理解的学习,它是一个过程,是一个不断累积、不断沉淀、不断总结、善于传达自己的个人见解以及乐于分享的过程。
程序员必须掌握的核心算法有哪些?
由于我之前一直强调数据结构以及算法学习的重要性,所以就有一些读者经常问我,数据结构与算法应该要学习到哪个程度呢?,说实话,这个问题我不知道要怎么回答你,主要取决于你想学习到哪些程度,不过针对这个问题,我稍微总结一下我学过的算法知识点,以及我觉得值得学习的算法。这些算法与数据结构的学习大多数是零散的,并没有一本把他们全部覆盖的书籍。下面是我觉得值得学习的一些算法以及数据结构,当然,我也会整理一些看过...
大学四年自学走来,这些私藏的实用工具/学习网站我贡献出来了
大学四年,看课本是不可能一直看课本的了,对于学习,特别是自学,善于搜索网上的一些资源来辅助,还是非常有必要的,下面我就把这几年私藏的各种资源,网站贡献出来给你们。主要有:电子书搜索、实用工具、在线视频学习网站、非视频学习网站、软件下载、面试/求职必备网站。 注意:文中提到的所有资源,文末我都给你整理好了,你们只管拿去,如果觉得不错,转发、分享就是最大的支持了。 一、电子书搜索 对于大部分程序员...
linux系列之常用运维命令整理笔录
本博客记录工作中需要的linux运维命令,大学时候开始接触linux,会一些基本操作,可是都没有整理起来,加上是做开发,不做运维,有些命令忘记了,所以现在整理成博客,当然vi,文件操作等就不介绍了,慢慢积累一些其它拓展的命令,博客不定时更新 free -m 其中:m表示兆,也可以用g,注意都要小写 Men:表示物理内存统计 total:表示物理内存总数(total=used+free) use...
比特币原理详解
一、什么是比特币 比特币是一种电子货币,是一种基于密码学的货币,在2008年11月1日由中本聪发表比特币白皮书,文中提出了一种去中心化的电子记账系统,我们平时的电子现金是银行来记账,因为银行的背后是国家信用。去中心化电子记账系统是参与者共同记账。比特币可以防止主权危机、信用风险。其好处不多做赘述,这一层面介绍的文章很多,本文主要从更深层的技术原理角度进行介绍。 二、问题引入 假设现有4个人...
程序员接私活怎样防止做完了不给钱?
首先跟大家说明一点,我们做 IT 类的外包开发,是非标品开发,所以很有可能在开发过程中会有这样那样的需求修改,而这种需求修改很容易造成扯皮,进而影响到费用支付,甚至出现做完了项目收不到钱的情况。 那么,怎么保证自己的薪酬安全呢? 我们在开工前,一定要做好一些证据方面的准备(也就是“讨薪”的理论依据),这其中最重要的就是需求文档和验收标准。一定要让需求方提供这两个文档资料作为开发的基础。之后开发...
网页实现一个简单的音乐播放器(大佬别看。(⊙﹏⊙))
今天闲着无事,就想写点东西。然后听了下歌,就打算写个播放器。 于是乎用h5 audio的加上js简单的播放器完工了。 演示地点演示 html代码如下` music 这个年纪 七月的风 音乐 ` 然后就是css`*{ margin: 0; padding: 0; text-decoration: none; list-...
Python十大装B语法
Python 是一种代表简单思想的语言,其语法相对简单,很容易上手。不过,如果就此小视 Python 语法的精妙和深邃,那就大错特错了。本文精心筛选了最能展现 Python 语法之精妙的十个知识点,并附上详细的实例代码。如能在实战中融会贯通、灵活使用,必将使代码更为精炼、高效,同时也会极大提升代码B格,使之看上去更老练,读起来更优雅。
数据库优化 - SQL优化
以实际SQL入手,带你一步一步走上SQL优化之路!
通俗易懂地给女朋友讲:线程池的内部原理
餐盘在灯光的照耀下格外晶莹洁白,女朋友拿起红酒杯轻轻地抿了一小口,对我说:“经常听你说线程池,到底线程池到底是个什么原理?”
经典算法(5)杨辉三角
杨辉三角 是经典算法,这篇博客对它的算法思想进行了讲解,并有完整的代码实现。
使用 Docker 部署 Spring Boot 项目
Docker 技术发展为微服务落地提供了更加便利的环境,使用 Docker 部署 Spring Boot 其实非常简单,这篇文章我们就来简单学习下。首先构建一个简单的 S...
英特尔不为人知的 B 面
从 PC 时代至今,众人只知在 CPU、GPU、XPU、制程、工艺等战场中,英特尔在与同行硬件芯片制造商们的竞争中杀出重围,且在不断的成长进化中,成为全球知名的半导体公司。殊不知,在「刚硬」的背后,英特尔「柔性」的软件早已经做到了全方位的支持与支撑,并持续发挥独特的生态价值,推动产业合作共赢。 而对于这一不知人知的 B 面,很多人将其称之为英特尔隐形的翅膀,虽低调,但是影响力却不容小觑。 那么,在...
面试官:你连RESTful都不知道我怎么敢要你?
干货,2019 RESTful最贱实践
刷了几千道算法题,这些我私藏的刷题网站都在这里了!
遥想当年,机缘巧合入了 ACM 的坑,周边巨擘林立,从此过上了"天天被虐似死狗"的生活… 然而我是谁,我可是死狗中的战斗鸡,智力不够那刷题来凑,开始了夜以继日哼哧哼哧刷题的日子,从此"读题与提交齐飞, AC 与 WA 一色 ",我惊喜的发现被题虐既刺激又有快感,那一刻我泪流满面。这么好的事儿作为一个正直的人绝不能自己独享,经过激烈的颅内斗争,我决定把我私藏的十几个 T 的,阿不,十几个刷题网...
白话阿里巴巴Java开发手册高级篇
不久前,阿里巴巴发布了《阿里巴巴Java开发手册》,总结了阿里巴巴内部实际项目开发过程中开发人员应该遵守的研发流程规范,这些流程规范在一定程度上能够保证最终的项目交付质量,通过在时间中总结模式,并推广给广大开发人员,来避免研发人员在实践中容易犯的错误,确保最终在大规模协作的项目中达成既定目标。 无独有偶,笔者去年在公司里负责升级和制定研发流程、设计模板、设计标准、代码标准等规范,并在实际工作中进行...
SQL-小白最佳入门sql查询一
不要偷偷的查询我的个人资料,即使你再喜欢我,也不要这样,真的不好;
redis分布式锁,面试官请随便问,我都会
文章有点长并且绕,先来个图片缓冲下! 前言 现在的业务场景越来越复杂,使用的架构也就越来越复杂,分布式、高并发已经是业务要求的常态。像腾讯系的不少服务,还有CDN优化、异地多备份等处理。 说到分布式,就必然涉及到分布式锁的概念,如何保证不同机器不同线程的分布式锁同步呢? 实现要点 互斥性,同一时刻,智能有一个客户端持有锁。 防止死锁发生,如果持有锁的客户端崩溃没有主动释放锁,也要保证锁可以正常释...
项目中的if else太多了,该怎么重构?
介绍 最近跟着公司的大佬开发了一款IM系统,类似QQ和微信哈,就是聊天软件。我们有一部分业务逻辑是这样的 if (msgType = "文本") { // dosomething } else if(msgType = "图片") { // doshomething } else if(msgType = "视频") { // doshomething } else { // doshom...
Nginx 原理和架构
Nginx 是一个免费的,开源的,高性能的 HTTP 服务器和反向代理,以及 IMAP / POP3 代理服务器。Nginx 以其高性能,稳定性,丰富的功能,简单的配置和低资源消耗而闻名。 Nginx 的整体架构 Nginx 里有一个 master 进程和多个 worker 进程。master 进程并不处理网络请求,主要负责调度工作进程:加载配置、启动工作进程及非停升级。worker 进程负责处...
“狗屁不通文章生成器”登顶GitHub热榜,分分钟写出万字形式主义大作
一、垃圾文字生成器介绍 最近在浏览GitHub的时候,发现了这样一个骨骼清奇的雷人项目,而且热度还特别高。 项目中文名:狗屁不通文章生成器 项目英文名:BullshitGenerator 根据作者的介绍,他是偶尔需要一些中文文字用于GUI开发时测试文本渲染,因此开发了这个废话生成器。但由于生成的废话实在是太过富于哲理,所以最近已经被小伙伴们给玩坏了。 他的文风可能是这样的: 你发现,...
程序员:我终于知道post和get的区别
是一个老生常谈的话题,然而随着不断的学习,对于以前的认识有很多误区,所以还是需要不断地总结的,学而时习之,不亦说乎
《程序人生》系列-这个程序员只用了20行代码就拿了冠军
你知道的越多,你不知道的越多 点赞再看,养成习惯GitHub上已经开源https://github.com/JavaFamily,有一线大厂面试点脑图,欢迎Star和完善 前言 这一期不算《吊打面试官》系列的,所有没前言我直接开始。 絮叨 本来应该是没有这期的,看过我上期的小伙伴应该是知道的嘛,双十一比较忙嘛,要值班又要去帮忙拍摄年会的视频素材,还得搞个程序员一天的Vlog,还要写BU...
加快推动区块链技术和产业创新发展,2019可信区块链峰会在京召开
11月8日,由中国信息通信研究院、中国通信标准化协会、中国互联网协会、可信区块链推进计划联合主办,科技行者协办的2019可信区块链峰会将在北京悠唐皇冠假日酒店开幕。   区块链技术被认为是继蒸汽机、电力、互联网之后,下一代颠覆性的核心技术。如果说蒸汽机释放了人类的生产力,电力解决了人类基本的生活需求,互联网彻底改变了信息传递的方式,区块链作为构造信任的技术有重要的价值。   1...
Java世界最常用的工具类库
Apache Commons Apache Commons有很多子项目 Google Guava 参考博客
程序员把地府后台管理系统做出来了,还有3.0版本!12月7号最新消息:已在开发中有github地址
第一幕:缘起 听说阎王爷要做个生死簿后台管理系统,我们派去了一个程序员…… 996程序员做的梦: 第一场:团队招募 为了应对地府管理危机,阎王打算找“人”开发一套地府后台管理系统,于是就在地府总经办群中发了项目需求。 话说还是中国电信的信号好,地府都是满格,哈哈!!! 经常会有外行朋友问:看某网站做的不错,功能也简单,你帮忙做一下? 而这次,面对这样的需求,这个程序员...
网易云6亿用户音乐推荐算法
网易云音乐是音乐爱好者的集聚地,云音乐推荐系统致力于通过 AI 算法的落地,实现用户千人千面的个性化推荐,为用户带来不一样的听歌体验。 本次分享重点介绍 AI 算法在音乐推荐中的应用实践,以及在算法落地过程中遇到的挑战和解决方案。 将从如下两个部分展开: AI算法在音乐推荐中的应用 音乐场景下的 AI 思考 从 2013 年 4 月正式上线至今,网易云音乐平台持续提供着:乐屏社区、UGC...
【技巧总结】位运算装逼指南
位算法的效率有多快我就不说,不信你可以去用 10 亿个数据模拟一下,今天给大家讲一讲位运算的一些经典例子。不过,最重要的不是看懂了这些例子就好,而是要在以后多去运用位运算这些技巧,当然,采用位运算,也是可以装逼的,不信,你往下看。我会从最简单的讲起,一道比一道难度递增,不过居然是讲技巧,那么也不会太难,相信你分分钟看懂。 判断奇偶数 判断一个数是基于还是偶数,相信很多人都做过,一般的做法的代码如下...
为什么要学数据结构?
一、前言 在可视化化程序设计的今天,借助于集成开发环境可以很快地生成程序,程序设计不再是计算机专业人员的专利。很多人认为,只要掌握几种开发工具就可以成为编程高手,其实,这是一种误解。要想成为一个专业的开发人员,至少需要以下三个条件: 1) 能够熟练地选择和设计各种数据结构和算法 2) 至少要能够熟练地掌握一门程序设计语言 3) 熟知所涉及的相关应用领域的知识 其中,后两个条件比较容易实现,而第一个...
Android 9.0 init 启动流程
阅读五分钟,每日十点,和您一起终身学习,这里是程序员Android本篇文章主要介绍Android开发中的部分知识点,通过阅读本篇文章,您将收获以下内容:一、启动流程概述一、 启动流程概述Android启动流程跟Linux启动类似,大致分为如下五个阶段。1.开机上电,加载固化的ROM。2.加载BootLoader,拉起Android OS。3.加载Uboot,初始外设,引导Kernel启动等。...
相关热词 c# 二进制截断字符串 c#实现窗体设计器 c#检测是否为微信 c# plc s1200 c#里氏转换原则 c# 主界面 c# do loop c#存为组套 模板 c# 停掉协程 c# rgb 读取图片
立即提问