spring aop 动态代理 报错

警告: Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userService' defined in class path resource [spring.xml]: BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor#0': Cannot resolve reference to bean 'pointcut' while setting bean property 'pointcut'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'pointcut': Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.aop.aspectj.AspectJExpressionPointcut]: No default constructor found; nested exception is java.lang.NoClassDefFoundError: org/aspectj/weaver/reflect/ReflectionWorld$ReflectionWorldException
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userService' defined in class path resource [spring.xml]: BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor#0': Cannot resolve reference to bean 'pointcut' while setting bean property 'pointcut'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'pointcut': Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.aop.aspectj.AspectJExpressionPointcut]: No default constructor found; nested exception is java.lang.NoClassDefFoundError: org/aspectj/weaver/reflect/ReflectionWorld$ReflectionWorldException
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:479)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:312)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:308)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543)
at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:83)
at Client.main(Client.java:21)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor#0': Cannot resolve reference to bean 'pointcut' while setting bean property 'pointcut'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'pointcut': Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.aop.aspectj.AspectJExpressionPointcut]: No default constructor found; nested exception is java.lang.NoClassDefFoundError: org/aspectj/weaver/reflect/ReflectionWorld$ReflectionWorldException
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:359)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:108)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1537)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1284)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:312)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:308)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
at org.springframework.aop.framework.autoproxy.BeanFactoryAdvisorRetrievalHelper.findAdvisorBeans(BeanFactoryAdvisorRetrievalHelper.java:92)
at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findCandidateAdvisors(AbstractAdvisorAutoProxyCreator.java:102)
at org.springframework.aop.aspectj.autoproxy.AspectJAwareAdvisorAutoProxyCreator.shouldSkip(AspectJAwareAdvisorAutoProxyCreator.java:103)
at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessBeforeInstantiation(AbstractAutoProxyCreator.java:248)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInstantiation(AbstractAutowireCapableBeanFactory.java:1045)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.resolveBeforeInstantiation(AbstractAutowireCapableBeanFactory.java:1019)
xml 配置文件


aop:config
/aop:pointcut
/aop:advisor
/aop:config

            test 类
             ApplicationContext applicationContext=new ClassPathXmlApplicationContext("spring.xml");
    UserService userService=(UserService)applicationContext.getBean("userService");
    userService.add();

1个回答

No default constructor found

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
Spring AOP动态代理

本人最近因工作需求学习了下应用AOP,遇到一个很棘手的Spring AOP应用问题,希望各位大牛能帮忙提点。 问题如下,现在做一个迁移项目,要把原来的一个登录机制改为spring 动态代理拦截。我直接把他原来的登录机制去掉是可以运行的,一旦加上aop配置就报错,是前台报的。 错误信息如下: (mx.rpc::Fault)#0 content = (null) errorID = 0 faultCode = "Server.ResourceUnavailable" faultDetail = "Method 'getGlobalData' not found." faultString = "Cannot invoke method 'getGlobalData'." message = "faultCode:Server.ResourceUnavailable faultString:'Cannot invoke method 'getGlobalData'.' faultDetail:'Method 'getGlobalData' not found.'" name = "Error" rootCause = (null) 项目主要用到flex+spring+oracle技术,其中flex应用了cairngorn框架。 我的aop配置如下: <bean id="flexRoAdvice" class="com.ssgm.ficoms.controller.flex.FlexROAdvice" /> <bean class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator"> <property name="beanNames"> <list> <value>flexRO</value> </list> </property> <property name="interceptorNames"> <list> <value>methodNameAdvisor</value> </list> </property> </bean> <bean id="methodNameAdvisor" class="org.springframework.aop.support.DefaultPointcutAdvisor"> <property name="pointcut" ref="methodNamePointcut" /> <property name="advice" ref="flexRoAdvice" /> </bean> <bean id="methodNamePointcut" class="org.springframework.aop.support.NameMatchMethodPointcut"> <!-- <property name="mappedNames"> <list> <value>getUserAuthori*</value> <value>getGlobalData</value> </list> </property> --> <property name="mappedName" value="getUserAuthorization" /> </bean> 希望各位大牛给予帮助?小弟在此谢过

新人求助:springAOP自动代理配置

如下,这是源码 接口 ``` package test.spring.aop.bean; public interface Eatable { public void eat(); } ``` 实现类 ``` package test.spring.aop.bean; public class EatLunch implements Eatable { public void eat() { System.out.println("吃午饭..."); } } ``` 通知 ``` package test.spring.aop.bean; import java.lang.reflect.Method; import org.springframework.aop.AfterReturningAdvice; import org.springframework.aop.MethodBeforeAdvice; public class EatHelper implements MethodBeforeAdvice,AfterReturningAdvice{ public void afterReturning(Object arg0, Method arg1, Object[] arg2, Object arg3) throws Throwable { System.out.println("吃完饭去刷牙了。。"); } public void before(Method arg0, Object[] arg1, Object arg2) throws Throwable { System.out.println("要吃饭了,去洗手了。。"); } } ``` Spring配置文件 app3.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:context="http://www.springframework.org/schema/context" xmlns:jdbc="http://www.springframework.org/schema/jdbc" xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:util="http://www.springframework.org/schema/util" xmlns:jpa="http://www.springframework.org/schema/data/jpa" 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/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.2.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.2.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa-1.3.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 http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.2.xsd"> <!-- SpringAOP学习 Spring自动代理 --> <bean id="eatLunch" class="test.spring.aop.bean.EatLunch"></bean> <!-- SpringAOP学习之配置文件第1步 配置通知bean--> <bean id="eatHelper" class="test.spring.aop.bean.EatHelper"> </bean> <!-- SpringAOP学习之配置文件第2步 配置切点通知者--> <bean id="eatHelperAdvisor" class="org.springframework.aop.support.RegexpMethodPointcutAdvisor"> <property name="advice" ref="eatHelper"></property> <property name="pattern" ref=".*eat"></property> </bean> <!-- SpringAOP学习之配置文件第3步 自动代理对象--> <bean class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator"> </bean> </beans> ``` junit测试类 ``` package test; import org.junit.Test; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import test.spring.aop.bean.Eatable; public class Test_SpringAop2 { @Test public void test1(){ ApplicationContext appCtx = new ClassPathXmlApplicationContext("app3.xml"); Eatable eatable = (Eatable)appCtx.getBean("eatLunch"); eatable.eat(); } } ``` 运行之后junit报错,如下: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'eatLunch' defined in class path resource [app3.xml]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'eatHelperAdvisor' defined in class path resource [app3.xml]: Cannot resolve reference to bean '.*eat' while setting bean property 'pattern'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named '.*eat' is defined 采用手动代理配置可以得到正确结果,如下: ![图片说明](https://img-ask.csdn.net/upload/201609/26/1474871781_421978.png)

关于spring aop的cglib代理什么时候才起作用

网上的文章都说 <aop:aspectj-autoproxy proxy-target-class="true"></aop:aspectj-autoproxy>配置了这句话的话就会强制使用cglib代理,如果proxy-target-class改成"false"的话就会先使用jdk动态代理如果不是接口来实现的话再使用cglib代理,但是我实验的时候如果proxy-target-class改成false的话永远是使用jdk动态代理啊,我也加了cglib的jar包了,这是为什么啊 难道网上说的都是错的?

SpringAoP无法切入问题,请大神指导

在做AoP练习时,AoP总是无法切入,请各位大大赐教 ### 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:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc" 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-3.1.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.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"> <!-- 自动扫描 --> <context:component-scan base-package="com.gwc.shop" /> <!--自动代理--> <aop:aspectj-autoproxy proxy-target-class="true"/> <!-- 引入配置文件 --> <context:property-placeholder location="classpath:properties/jdbc.properties"/> ``` ### 代理类 ``` @Component @Aspect public class AoPUtils { @Pointcut("execution(* com.gwc.shop.entity.Goods.*(..))") public void aspect(){ } @Before("aspect()") public void before(JoinPoint joinPoint){ System.out.println("before"); System.out.println(joinPoint.getArgs().toString()); System.out.println(joinPoint.getKind()); System.out.println(joinPoint.getSignature()); System.out.println(joinPoint.getTarget()); } @After("aspect()") public void after(JoinPoint joinPoint){ System.out.println("after"); } @Around("aspect()") public void around(JoinPoint joinPoint){ try { Object[] args = joinPoint.getArgs(); for (Object arg : args) { System.out.println(arg.toString()); } Object proceed = ((ProceedingJoinPoint) joinPoint).proceed(); if (proceed!=null) System.out.println(proceed.toString()); } catch (Throwable throwable) { throwable.printStackTrace(); } } ``` ### 被代理类如下 ``` @Component(value = "goods") public class Goods { private Long id; private String name; private Long count; //assortment的id private Long belongs; ``` ### 测试类如下: ``` @Test public void test(){ ApplicationContext context = new AnnotationConfigApplicationContext("com.gwc.shop.entity"); Goods goods = ((Goods) context.getBean("goods")); goods.setBelongs(123L); goods.getBelongs(); String name = "zhangsan"; name = name.concat("123"); System.out.println(name); } ``` 我的测试类没有添加Spring的注解,难道和这个有关... 执行不报错,只是没有切入!

一个关于Spring AOP的问题

先说一下情况:小弟现正用Spring AOP实现日志记录功能,上面交待Web层,Service层,Dao层都要记录,所以打算在Web层只记一下用户请求的情况,也就是说用户请求哪个Action时,记录一下操作步骤,Service层记录方法调用时的参数及返回值以及异常情况,Dao层上面交待要记录最终SQL(这个小弟现在还不知道怎么实现)。 在此只说一下Web层的日志记录,其它的略过了。我是这样的,先定义一个名为ActionName的annotation,有一个value属性,这个value属性的值就表示该Action方法的功能说明。然后我定义一个Pointcut匹配该annotation。到这里一切都没问题,能正常拦截并代理Action方法,但是前提是必须使用CGLIB! 我记得好像Spring能自动地判断目标方法并决定是使用动态代理还是CGLIB代理实现的。但是我在配置文件中如果不强制使用CGLIB代理则程序运行报错呢? 下面是我的代码: LogHandler类 package com.delver.bms.log.util; import java.lang.reflect.Method; import java.sql.Timestamp; import org.aspectj.lang.JoinPoint; 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 com.delver.bms.exception.BusinessException; import com.delver.bms.log.annotation.ActionName; import com.delver.bms.log.annotation.TaskScheduling; import com.delver.bms.log.dao.IAppLogDao; import com.delver.bms.log.to.AppLog; import com.delver.bms.util.AutoID32; import com.delver.bms.util.TenantUtil; import com.ibm.crl.mmt.datamodel.MTUtilFactory; import com.ibm.crl.mmt.exception.MTException; /** * 日志记录切面类 * * @author yue.ch * */ @Aspect public class LogHandler { private IAppLogDao appLogDao; public void setAppLogDao(IAppLogDao appLogDao) { this.appLogDao = appLogDao; } /** * 定义切入点,匹配使用@ActionName注解的方法 * @param actionName @ActionName注解value值(功能解释) */ @Pointcut("@annotation(actionName)") public void annotationMethod(ActionName actionName) { } /** * 定义切入点,匹配使用@TaskScheduling注解的方法 * @param taskScheduling @TashScheduling注解value值(功能解释) */ @Pointcut("@annotation(taskScheduling)") public void annotationTaskMethod(TaskScheduling taskScheduling) { } /** * 定义切入点,匹配Service层方法 */ @Pointcut("execution(* com.delver.bms.*.service.*.*(..))") public void serviceMethod() { } /** * 定义切入点,排除UserDetailsServiceImpl类 */ @Pointcut("!within(com.delver.bms.identity.service.UserDetailsServiceImpl)") public void identityServiceMethod(){} /** * 定义切入点,排除日志记录功能模块的Service层方法 */ @Pointcut("!execution(* com.delver.bms.log.service.*.*(..))") public void logServiceMethod(){} /** * 定义切入点,排除日志记录功能模块的Dao层方法 */ @Pointcut("!execution(* com.delver.bms.log.dao.*.*(..))") public void logDaoMethod(){} /** * 定义切入点,匹配Dao层方法 */ @Pointcut("execution(* com.delver.bms.*.dao.*.*(..))") public void daoMethod(){} /** * 系统任务调度方法前置通知(记录任务调度方法功能说明及执行) * * @param joinPoint * @param taskScheduling */ @Around("annotationTaskMethod(taskScheduling)") public void aroundTaskScheduling(ProceedingJoinPoint joinPoint, TaskScheduling taskScheduling) throws Throwable { System.out.println("ddd"); } /** * Action方法前置通知(记录Action方法功能说明) * * @param joinPoint * @param actionName */ @Before("annotationMethod(actionName)") public void beforeActionLog(JoinPoint joinPoint, ActionName actionName) { System.out.println("ddd"); } /** * Service方法环绕通知 * * @param joinPoint * @return */ @Around("serviceMethod() && identityServiceMethod() && logServiceMethod()") public Object aroundServiceLog(ProceedingJoinPoint joinPoint) throws Throwable { System.out.println("ddd"); } /** * Dao方法环绕通知(记录SQL) * * @param jointPoint * @return */ @Around("daoMethod() && logDaoMethod()") public Object aroundDaoLog(ProceedingJoinPoint joinPoint) throws Throwable { System.out.println("ddd"); } 配置文件: <?xml version="1.0" encoding="utf-8"?> <beans xmlns="http://www.springframework.org/schema/beans" 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.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd"> <aop:aspectj-autoproxy proxy-target-class="true"/> <bean id="appLogDao" class="com.delver.bms.log.dao.AppLogDaoiBatis"> <property name="sqlMapClient" ref="sqlMapClient" /> </bean> <bean id="appLogManager" class="com.delver.bms.log.service.AppLogManagerImpl"> <property name="appLogDao" ref="appLogDao" /> </bean> <bean id="appLogInfo" class="com.delver.bms.log.web.AppLogInfo" scope="prototype"> <property name="appLogManager" ref="appLogManager" /> <property name="tenantManager" ref="tenantManager" /> </bean> <!-- 系统日志处理类 --> <bean id="appLogHandler" class="com.delver.bms.log.util.LogHandler"> <property name="appLogDao" ref="appLogDao" /> </bean> </beans> 异常信息: java.lang.NoSuchMethodException: $Proxy51.visit() at java.lang.Class.getMethod(Unknown Source) at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.getActionMethod(AnnotationValidationInterceptor.java:55) at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:41) at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86) at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224) at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223) at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221) at com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:123) 下面略。。。 [b]问题补充:[/b] 我希望的是Service层,Dao层用动态代理,web层用CGLIB代理,是不是不能实现?我试过配多个<aop:config>,但是只要其中有一个配置了proxy-target-class="true",就全都用CGLIB实现了,网上搜了下,貌似确实是这样的。还有,CGLIB代理与动态代理在运行期性能上有区别吗?

spring的AOP实现可以使用JDK的动态代理,为什么一定要使用接口,谁能说一下它的本质?谢谢!!

:( 请帮忙讨论一下

使用Spring代理来实现AOP时,业务类一定要用到接口吗,我没有接口,直接是类难道不行?

<bean id="proxyFactoryBean" class="org.springframework.aop.framework.ProxyFactoryBean" abstract="true"> <property name="proxyTargetClass" value="true"></property> <property name="interceptorNames"> <list> // ... 暂时没有 </list> </property> </bean> <bean id="userServiceProxy" parent="proxyFactoryBean"> <property name="proxyInterfaces" value="com.tipf.project.service.UserService" /> <property name="target" ref="userService"></property> </bean> com.tipf.project.service.UserService这个是个类,而不是接口 启动服务器报错 UserService is not an interface 请问如何解决

springAOP使用问题求教

最近在网上学SpringAOP的使用,自己模仿网上的博文写程序,其中配置文件如下: <?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-3.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.2.xsd"> 通知/目标方法被拦截前后的具体操作内容 《bean id="helper" class="aop.Helper"></bean》 定义切点(事件发生地点) 《bean id="cutPoint" class="org.springframework.aop.support.JdkRegexpMethodPointcut"> 《property name="pattern" value=".*targetMethod"></property》 /bean> 关联切点和通知 《bean id="advisorWithCutpoint" class="org.springframework.aop.support.DefaultPointcutAdvisor"> 《property name="cutPoint" ref="cutPoint">《/property> 《property name="advisor" ref="helper">《/property> 《/bean> 配置代理 《bean id="proxy" class="org.springframework.aop.framework.ProxyFactoryBean"> 《property name="target" ref="target">《/property> 《property name="cutFace" value="advisorWithCutpoint">《/property> 《property name="targetInterface" value="aop.TargetInterface">《/property> 《/bean> 运行时程序报错:Bean property 'cutPoint' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter? 这个错涉及到的bean是配置文件中 ”关联切点和通知 ”部分的。很明显是没有注入cutPoint引起的,但是advisorWithCutpoint对应的类是个框架中的类org.springframework.aop.support.DefaultPointcutAdvisor,自己不能修改,怎么将cutPoint注入到框架类中呢?(自定义类可以在其中写get方法或使用注解注入,但这个是往框架类中注入bean,怎么注入呢?)

初学Spring aop ,遇到了object is not an instance of declaring class的问题

CompareInterceptor类 package com.spring.advice; import org.aopalliance.intercept.MethodInterceptor; import org.aopalliance.intercept.MethodInvocation; public class CompareInterceptor implements MethodInterceptor { @Override public Object invoke(MethodInvocation invocation) throws Throwable { // TODO Auto-generated method stub Object result = null; String sname = invocation.getArguments()[0].toString(); if(sname.equals("forever")){ result = invocation.proceed(); } else{ System.out.println("此学生是:"+sname+",而不是forever"); } return result; } } Test 类 package com.spring.test; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import com.spring.aop.Istudent; public class Test { public static void main(String args[]){ ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml"); Istudent st = (Istudent)context.getBean("student"); st.addStudent("forever"); } } applicationContext.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:p="http://www.springframework.org/schema/p" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"> <bean id="beforeAdvice" class="com.spring.advice.BeforeAdvice" /> <bean id="afterAdvice" class="com.spring.advice.AfterAdvice" /> <bean id="compareInterceptor" class="com.spring.advice.CompareInterceptor" /> <bean id="studentTarget" class="com.spring.aop.StudentImpl" /> <bean id="student" class="org.springframework.aop.framework.ProxyFactoryBean" > <property name="proxyInterfaces"> <value>com.spring.aop.Istudent</value> </property> <property name="interceptorNames"> <list> <value>beforeAdvice</value> <value>afterAdvice</value> <value>compareInterceptor</value> </list> </property> <property name="target"> <value>studentTarget</value> </property> </bean> </beans> 只要不是参数不是forever,一切都正常。。。求帮助!

初学spring aop 遇到了object is not an instance of declaring class的问题

CompareInterceptor类 package com.spring.advice; import org.aopalliance.intercept.MethodInterceptor; import org.aopalliance.intercept.MethodInvocation; public class CompareInterceptor implements MethodInterceptor { @Override public Object invoke(MethodInvocation invocation) throws Throwable { // TODO Auto-generated method stub Object result = null; String sname = invocation.getArguments()[0].toString(); if(sname.equals("forever")){ result = invocation.proceed(); } else{ System.out.println("此学生是:"+sname+",而不是forever"); } return result; } } Test 类 package com.spring.test; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import com.spring.aop.Istudent; public class Test { public static void main(String args[]){ ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml"); Istudent st = (Istudent)context.getBean("student"); st.addStudent("forever"); } } applicationContext.xml <?xml version="1.0" encoding="UTF-8"?> xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"> <bean id="beforeAdvice" class="com.spring.advice.BeforeAdvice" /> <bean id="afterAdvice" class="com.spring.advice.AfterAdvice" /> <bean id="compareInterceptor" class="com.spring.advice.CompareInterceptor" /> <bean id="studentTarget" class="com.spring.aop.StudentImpl" /> <bean id="student" class="org.springframework.aop.framework.ProxyFactoryBean" > <property name="proxyInterfaces"> <value>com.spring.aop.Istudent</value> </property> <property name="interceptorNames"> <list> <value>beforeAdvice</value> <value>afterAdvice</value> <value>compareInterceptor</value> </list> </property> <property name="target"> <value>studentTarget</value> </property> </bean> 只要不是参数不是forever,一切都正常。。。求帮助!

spring mvc serviceImpl层报错了,求解

这个是配置文件: <?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.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 "> <!-- <import resource="ApplicationContext-service.xml"/> --> <!--建立数据源 --> <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <!--数据库驱动,我这里使用的是oracle数据库--> <property name="driverClassName" value="oracle.jdbc.OracleDriver"/> <property name="username" value="xinhuitest"/> <property name="password" value="xinhui123"/> <property name="url" value="jdbc:oracle:thin:@localhost:1521:orcl"/> </bean> <!-- 把数据源注入给Session工厂--> <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource" ref="dataSource"/> <property name="configLocation" value="classpath:mybatis/config.xml"/> </bean> <bean id="sqlSession" class="org.mybatis.spring.SqlSessionTemplate"> <constructor-arg index="0" ref="sqlSessionFactory"></constructor-arg> </bean> <!-- 扫描 basePackage下所有的接口,根据对应的mapper.xml为其生成代理类--> <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> <property name="basePackage" value="com.perpare.mapper" /> </bean> <!-- 事务管理器 --> <bean name="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="dataSource"></property> </bean> <!-- 事务属性 --> <tx:advice id="txAdvice" transaction-manager="transactionManager"> <tx:attributes> <tx:method name="delete*" propagation="REQUIRED" read-only="false" rollback-for="java.lang.Exception"/> <tx:method name="insert*" propagation="REQUIRED" read-only="false" rollback-for="java.lang.Exception" /> <tx:method name="update*" propagation="REQUIRED" read-only="false" rollback-for="java.lang.Exception" /> <tx:method name="save*" propagation="REQUIRED" read-only="false" rollback-for="java.lang.Exception" /> <tx:method name="*" propagation="REQUIRED" read-only="true"/> </tx:attributes> </tx:advice> <!-- 织入 --> <aop:config> <aop:pointcut id="pc" expression="execution(* com.perpare.service..*(..))" /> <aop:advisor pointcut-ref="pc" advice-ref="txAdvice" /> </aop:config> </beans> 这个是注解 <?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:mvc="http://www.springframework.org/schema/mvc" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"> <!-- 使Spring支持自动检测组件,如注解的Controller --> <mvc:annotation-driven/> <context:component-scan base-package="com.perpare.*" use-default-filters="false"> <context:include-filter type="annotation" expression="org.springframework.stereotype.Service" /> <context:include-filter type="annotation" expression="org.springframework.stereotype.Repository" /> </context:component-scan> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/jsp/"/> <property name="suffix" value=".jsp"/> </bean> </beans> java代码: @Service @Transactional public class PlayersServiceImpl implements PlayersService { @Autowired PlayersMapper playersMapper; public List<Players> searchPlayerList() { return playersMapper.searchPlayerList(); } } 下面是报错信息: 严重: StandardWrapper.Throwable org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'playersServiceImpl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.perpare.mapper.PlayersMapper com.perpare.service.PlayersServiceImpl.playersMapper; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [com.perpare.mapper.PlayersMapper] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:285) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1074) 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:291) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:580) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425) at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:442) at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:458) at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:339) at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:306) at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:127) at javax.servlet.GenericServlet.init(GenericServlet.java:212) at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1173) at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:993) at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4421) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4734) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:601) at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1079) at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:1002) at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:506) at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1317) at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:324) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1065) at org.apache.catalina.core.StandardHost.start(StandardHost.java:840) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463) at org.apache.catalina.core.StandardService.start(StandardService.java:525) at org.apache.catalina.core.StandardServer.start(StandardServer.java:754) at org.apache.catalina.startup.Catalina.start(Catalina.java:595) 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:289) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414) Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.perpare.mapper.PlayersMapper com.perpare.service.PlayersServiceImpl.playersMapper; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [com.perpare.mapper.PlayersMapper] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:502) at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:84) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:282) ... 42 more Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [com.perpare.mapper.PlayersMapper] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:920) at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:789) at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:703) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:474) ... 44 more 2014-5-19 22:46:32 org.apache.catalina.core.StandardContext loadOnStartup 严重: Servlet /perpareToJs threw load() exception org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [com.perpare.mapper.PlayersMapper] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:920) at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:789) at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:703) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:474) at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:84) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:282) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1074) 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:291) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:580) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425) at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:442) at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:458) at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:339) at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:306) at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:127) at javax.servlet.GenericServlet.init(GenericServlet.java:212) at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1173) at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:993) at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4421) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4734) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:601) at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1079) at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:1002) at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:506) at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1317) at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:324) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1065) at org.apache.catalina.core.StandardHost.start(StandardHost.java:840) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463) at org.apache.catalina.core.StandardService.start(StandardService.java:525) at org.apache.catalina.core.StandardServer.start(StandardServer.java:754) at org.apache.catalina.startup.Catalina.start(Catalina.java:595) 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:289) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)

Java怎么实现多层动态代理(优雅的方式)

用cglib两层代理后会报错 ``` Enhancer enhancer = new Enhancer(); enhancer.setSuperclass(Hello.class); enhancer.setCallback(new TestAop()); Hello hello = (Hello)enhancer.create(); Enhancer enhancer1 = new Enhancer(); enhancer1.setSuperclass(hello.getClass()); enhancer1.setCallback(new TestAop()); Hello hello2 = (Hello)enhancer1.create(); System.out.println(hello2.getClass()); hello2.dd(); ``` 报错 ``` at net.sf.cglib.core.ReflectUtils.defineClass(ReflectUtils.java:413) at net.sf.cglib.core.AbstractClassGenerator.generate(AbstractClassGenerator.java:336) ... 12 more Caused by: java.lang.ClassFormatError: Duplicate method name&signature in class file tk/tankpao/blast/util/Hello$$EnhancerByCGLIB$$59850fd3$$EnhancerByCGLIB$$2199b39 at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:760) ... 18 more ``` 有没类似的方式实现多层代理(优雅,cglib类似的工具库已经提供了多层代理的功能)。 通过往一个切面里织入多次代码,也能实现多次代理,但是本人觉得不够优雅。

Spring 与 Cglib代理的诡异问题

一个普通的业务对象 没有实现接口 通过cglib代理 [code="java"]public class UserDao { public void a() { System.out.println("aa"); } public void b() { System.out.println("bb"); } public void c() { this.a(); this.b(); } }[/code] 这是实现了cglib的一个接口 以完成方法的拦截 [code="java"]public class T implements MethodInterceptor{ @Override public Object intercept(Object arg0, Method arg1, Object[] arg2, MethodProxy arg3) throws Throwable { System.out.println("before"); return arg3.invokeSuper(arg0, arg2); } }[/code] [code="java"] public static void main(String[] args) { Enhancer en = new Enhancer(); en.setSuperclass(UserDao.class); en.setCallbacks(new Callback[]{new T()}); UserDao dao = (UserDao) en.create(); dao.c(); } [/code] //这是通过CGLIB代理的测试 输出结果如下 before before aa before bb 每个方法都被拦截了 接下来问题来了 [code="java"] public static void main(String[] args) { BeanFactory beanFactory = new ClassPathXmlApplicationContext("spring-aop.xml"); UserDao dao = (UserDao) beanFactory.getBean("userdao"); dao.c(); }[/code] [code="java"] public void actionAop() { System.out.println("ControllerAopHandler.actionAop()"); }[/code] [code="java"] <bean id="userdao" class="com.gary.operation.demo.UserDao"></bean> <bean id="controllerAopHandler" class="com.gary.base.aop.ControllerAopHandler" /> <aop:config> <aop:aspect id="controllerAspect" ref="controllerAopHandler" order="1"> <aop:pointcut expression="execution(* com.gary.operation.demo.UserDao.*(..))" id="allMethod"/> <aop:before method="actionAop" pointcut-ref="allMethod"/> </aop:aspect> </aop:config> [/code] 这个代理对象是通过Spring容器拿出来的。那么因为没用使用接口 所以底层还是使用Cglib 但是输入结果却有所不同。 这是输出结果 ControllerAopHandler.actionAop() aa bb [size=small][color=red]也就是说C方法被拦截了 而a,b方法没有被拦截, 单独调用A,B方法均被拦截,那么后来我分析问题大概是出在这个地方[/color][/size] [code="java"] public void c() { //如果是通过cglib创建的代理 那么这里的this 还是指向代理对象 //所以当this.a的时候 还是通过UserDao$$EnhancerByCGLIB$$9e419b6.a()方法 //所以被拦截了 //反之就是用Spring创建的代理对象 那么这里的this 就变成了目标对象 所以没有被拦截 //我就不明白了 这到底是咋回事呢? System.out.println(this); this.a(); this.b(); }[/code] 真心请教Spring高手给指点一二

在spring3配置文件中用<aop:aspectj-autoproxy/>标签会报错,求解。

如题,在XML配置文件里加上<aop:aspectj-autoproxy/>就会报错。折腾了一下午,始终找不到原因。 把<aop:aspectj-autoproxy/>删除就又恢复正常。 org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.aop.config.internalAutoProxyCreator': Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/aopalliance/intercept/MethodInterceptor at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:955) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:901) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) at org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:710) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:410) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83) at com.shrx.service.test.UserServiceTest.addTest(UserServiceTest.java:15) 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.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184) at org.junit.runners.ParentRunner.run(ParentRunner.java:236) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:46) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/aopalliance/intercept/MethodInterceptor at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:141) at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:71) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:948) ... 35 more Caused by: java.lang.NoClassDefFoundError: org/aopalliance/intercept/MethodInterceptor at org.springframework.aop.framework.adapter.DefaultAdvisorAdapterRegistry.<init>(DefaultAdvisorAdapterRegistry.java:49) at org.springframework.aop.framework.adapter.GlobalAdvisorAdapterRegistry.<clinit>(GlobalAdvisorAdapterRegistry.java:31) at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.<init>(AbstractAutoProxyCreator.java:118) at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.<init>(AbstractAdvisorAutoProxyCreator.java:47) at org.springframework.aop.aspectj.autoproxy.AspectJAwareAdvisorAutoProxyCreator.<init>(AspectJAwareAdvisorAutoProxyCreator.java:46) at org.springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator.<init>(AnnotationAwareAspectJAutoProxyCreator.java:48) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:513) at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:126) ... 37 more Caused by: java.lang.ClassNotFoundException: org.aopalliance.intercept.MethodInterceptor at java.net.URLClassLoader$1.run(URLClassLoader.java:202) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:190) at java.lang.ClassLoader.loadClass(ClassLoader.java:307) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:248) ... 48 more

关于cglib动态代理的对象无法获取其属性注解的问题

``` @Service public class MarketMoneyChangeService{ @DynamicReference private IMarketBuyerProvider marketBuyerProvider; @Transactional(rollbackFor = Exception.class) public Boolean doChangeMoney() { return true; } } ``` 注解声明如下: ``` import java.lang.annotation.ElementType; import java.lang.annotation.Inherited; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** * 服务动态注入注解 */ @Inherited @Target(ElementType.FIELD) @Retention(RetentionPolicy.RUNTIME) public @interface DynamicReference { } ``` 代码中@DynamicReference为自定义注解, 作用是根据项目配置, 在运行时注入指定SpringBean或者Dubbo引用对象。正常情况下使用没问题, 但是当加上事务注解@Transactional时, MarketMoneyChangeService会变成cglib代理对象, 则使用Field无法获取到注解@DynamicReference ``` DynamicReference dynamicRefrence = filed.getAnnotation(DynamicReference.class); ``` 求解大佬, 被cglib代理的对象如何获取属性的注解, 或者cglib代理的对象如何设置其属性值

spring添加切面以后报BeanCreationException异常?

之前都没有问题只要添加了aop切面就报BeanCreationException异常 这是配置信息 ``` <!-- 扫描组件 --> <context:component-scan base-package="com.bookshop" ></context:component-scan> <bean class="org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor"/> <!-- 将数据资源加入ioc容器中 --> <context:property-placeholder location="classpath:db.properties"/> <bean id="comboPooledDataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"> <property name="driverClass" value="${jdbc.driver}"></property> <property name="jdbcUrl" value="${jdbc.url}"></property> <property name="user" value="${jdbc.user}"></property> <property name="password" value="${jdbc.pwd}"></property> </bean> <!-- 添加jdbcTemplate --> <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate"> <property name="dataSource" ref="comboPooledDataSource"></property> </bean> <!-- 基于注解使用aspectJ:主要作用是为切面中通知能作用得到的类添加代理类 --> <aop:aspectj-autoproxy/> <!-- 添加事务管理器 --> <bean id="dataSourceTransactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="comboPooledDataSource"></property> </bean> <!-- 开启事务注解 --> <tx:annotation-driven transaction-manager="dataSourceTransactionManager"/> ``` 这是切面 ``` @Aspect @Component public class Notice { @Pointcut("execution(public void com.bookshop.service.Impl.*(..))") public void Pointcut() {} @org.aspectj.lang.annotation.Before("Pointion()") public void beforaa(JoinPoint joinPoint) { String methodName = joinPoint.getSignature().getName(); System.out.println(methodName+" begin..."); } @org.aspectj.lang.annotation.After("Pointion()") public void afterbb(JoinPoint joinPoint) { Object object = joinPoint.getArgs(); System.out.println(object+" 购买成功!..."); } } ```

java动态代理测试报错

今天突然看到spring aop,想到代理模式,就写了个动态代理的例子,但是有点不遂人愿,出错了,各位大牛帮我看下哪里错了. 程序里头可能是有死循环或递归调用所产生的?增大JVM的内存? public interface Subject { void opration(); } public class RealSubject implements Subject { @Override public void opration() { System.out.println("I am a RealSubject"); } } public class ProxyInvocationHandler implements InvocationHandler { private Object beProxy; public ProxyInvocationHandler(Object beProxy) { super(); this.beProxy = beProxy; } @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { System.out.println("proxy class:" + proxy + "proxy method:" + method); return method.invoke(beProxy, args); } } public class TestDynamicProxy { public static void main(String[] args) { Subject proxyClass = (Subject) Proxy.newProxyInstance(Subject.class.getClassLoader(), new Class[] { Subject.class }, new ProxyInvocationHandler(new RealSubject())); proxyClass.opration(); } } Exception in thread "main" java.lang.StackOverflowError at java.lang.AbstractStringBuilder.<init>(AbstractStringBuilder.java:44) at java.lang.StringBuilder.<init>(StringBuilder.java:92) at com.test.dynamic.proxy.ProxyInvocationHandler.invoke(ProxyInvocationHandler.java:32) at com.sun.proxy.$Proxy0.toString(Unknown Source) at java.lang.String.valueOf(String.java:2826) at java.lang.StringBuilder.append(StringBuilder.java:115) at com.test.dynamic.proxy.ProxyInvocationHandler.invoke(ProxyInvocationHandler.java:32) at com.sun.proxy.$Proxy0.toString(Unknown Source) at java.lang.String.valueOf(String.java:2826) at java.lang.StringBuilder.append(StringBuilder.java:115) at com.test.dynamic.proxy.ProxyInvocationHandler.invoke(ProxyInvocationHandler.java:32) at com.sun.proxy.$Proxy0.toString(Unknown Source) at java.lang.String.valueOf(String.java:2826) at java.lang.StringBuilder.append(StringBuilder.java:115)

Spring代理getBean()只能返回接口类,否则报错的疑点

ApplicationContext ctx=new FileSystemXmlApplicationContext("WebContent\\WEB-INF\\spring.xml"); Vt vtb=(Vt)ctx.getBean("vt"); Mr mrb=(Mr) ctx.getBean("mr"); 两个类Mr和Vt是镜像的 public class Mr implements MindReader { private String thoughts; public void interceptThoughts(String thoughts) {System.out.println("hahaha"); this.thoughts=thoughts;} public String getThoughts() {return thoughts;} } public class Vt implements Thinker{ private String thoughts; public void thinkOfSomething(String thoughts) { this.thoughts=thoughts;} public String getThoughts() {return thoughts;} } 而且它们的接口也是镜像的 我实际调用的时候 Vt vtb=(Vt)ctx.getBean("vt"); ClassCastException报错,查了下资料代理默认创建必须要用接口类,换成Thinker vtb=(Thinker)ctx.getBean("vt"); 问题解决了。 但是Mr mrb=(Mr) ctx.getBean("mr");却没有任何异常可以正常使用,这是怎么回事?

springAOP代理

项目是sprin3+ibatis 问题出现在我用spring对ibatis事物管理,我是用AOP来申明的。 service和dao都是通过实现接口完成的。 但是报如下错误: [code="java"]org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userDao' defined in ServletContext resource [/WEB-INF/daoContext.xml]: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type '$Proxy4 implementing com.service.IUserService,org.springframework.orm.ibatis.SqlMapClientOperations,org.springframework.beans.factory.InitializingBean,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised' to required type 'org.springframework.orm.ibatis.SqlMapClientTemplate' for property 'sqlMapClientTemplate'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [$Proxy4 implementing com.service.IUserService,org.springframework.orm.ibatis.SqlMapClientOperations,org.springframework.beans.factory.InitializingBean,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised] to required type [org.springframework.orm.ibatis.SqlMapClientTemplate] for property 'sqlMapClientTemplate': no matching editors or conversion strategy found[/code] [code="java"]<!-- IBATIS的DAO的配置注入 --> <bean id="userDao" class="com.daoImpl.UserDaoImpl"> <property name="sqlMapClient" ref="sqlMapClient"/> </bean> [/code] [code="java"] <!-- 系统业务逻辑层的注入 --> <bean id="userService" class="com.serviceImpl.UserServiceImpl" > <property name="userDao" ref="userDao"></property> </bean>[/code] 在网上到解决方案, [color=red]<aop:aspectj-autoproxy proxy-target-class="true"/> [/color]。但是这个是强制aop用cglib来代理的。按理说,我的service和dao都实现了接口,应该是默认jdk动态代理,但为什么会报错呢?

大学四年自学走来,这些私藏的实用工具/学习网站我贡献出来了

大学四年,看课本是不可能一直看课本的了,对于学习,特别是自学,善于搜索网上的一些资源来辅助,还是非常有必要的,下面我就把这几年私藏的各种资源,网站贡献出来给你们。主要有:电子书搜索、实用工具、在线视频学习网站、非视频学习网站、软件下载、面试/求职必备网站。 注意:文中提到的所有资源,文末我都给你整理好了,你们只管拿去,如果觉得不错,转发、分享就是最大的支持了。 一、电子书搜索 对于大部分程序员...

在中国程序员是青春饭吗?

今年,我也32了 ,为了不给大家误导,咨询了猎头、圈内好友,以及年过35岁的几位老程序员……舍了老脸去揭人家伤疤……希望能给大家以帮助,记得帮我点赞哦。 目录: 你以为的人生 一次又一次的伤害 猎头界的真相 如何应对互联网行业的「中年危机」 一、你以为的人生 刚入行时,拿着傲人的工资,想着好好干,以为我们的人生是这样的: 等真到了那一天,你会发现,你的人生很可能是这样的: ...

程序员请照顾好自己,周末病魔差点一套带走我。

程序员在一个周末的时间,得了重病,差点当场去世,还好及时挽救回来了。

技术大佬:我去,你写的 switch 语句也太老土了吧

昨天早上通过远程的方式 review 了两名新来同事的代码,大部分代码都写得很漂亮,严谨的同时注释也很到位,这令我非常满意。但当我看到他们当中有一个人写的 switch 语句时,还是忍不住破口大骂:“我擦,小王,你丫写的 switch 语句也太老土了吧!” 来看看小王写的代码吧,看完不要骂我装逼啊。 private static String createPlayer(PlayerTypes p...

和黑客斗争的 6 天!

互联网公司工作,很难避免不和黑客们打交道,我呆过的两家互联网公司,几乎每月每天每分钟都有黑客在公司网站上扫描。有的是寻找 Sql 注入的缺口,有的是寻找线上服务器可能存在的漏洞,大部分都...

点沙成金:英特尔芯片制造全过程揭密

“亚马逊丛林里的蝴蝶扇动几下翅膀就可能引起两周后美国德州的一次飓风……” 这句人人皆知的话最初用来描述非线性系统中微小参数的变化所引起的系统极大变化。 而在更长的时间尺度内,我们所生活的这个世界就是这样一个异常复杂的非线性系统…… 水泥、穹顶、透视——关于时间与技艺的蝴蝶效应 公元前3000年,古埃及人将尼罗河中挖出的泥浆与纳特龙盐湖中的矿物盐混合,再掺入煅烧石灰石制成的石灰,由此得来了人...

讲一个程序员如何副业月赚三万的真实故事

loonggg读完需要3分钟速读仅需 1 分钟大家好,我是你们的校长。我之前讲过,这年头,只要肯动脑,肯行动,程序员凭借自己的技术,赚钱的方式还是有很多种的。仅仅靠在公司出卖自己的劳动时...

上班一个月,后悔当初着急入职的选择了

最近有个老铁,告诉我说,上班一个月,后悔当初着急入职现在公司了。他之前在美图做手机研发,今年美图那边今年也有一波组织优化调整,他是其中一个,在协商离职后,当时捉急找工作上班,因为有房贷供着,不能没有收入来源。所以匆忙选了一家公司,实际上是一个大型外包公司,主要派遣给其他手机厂商做外包项目。**当时承诺待遇还不错,所以就立马入职去上班了。但是后面入职后,发现薪酬待遇这块并不是HR所说那样,那个HR自...

女程序员,为什么比男程序员少???

昨天看到一档综艺节目,讨论了两个话题:(1)中国学生的数学成绩,平均下来看,会比国外好?为什么?(2)男生的数学成绩,平均下来看,会比女生好?为什么?同时,我又联想到了一个技术圈经常讨...

副业收入是我做程序媛的3倍,工作外的B面人生是怎样的?

提到“程序员”,多数人脑海里首先想到的大约是:为人木讷、薪水超高、工作枯燥…… 然而,当离开工作岗位,撕去层层标签,脱下“程序员”这身外套,有的人生动又有趣,马上展现出了完全不同的A/B面人生! 不论是简单的爱好,还是正经的副业,他们都干得同样出色。偶尔,还能和程序员的特质结合,产生奇妙的“化学反应”。 @Charlotte:平日素颜示人,周末美妆博主 大家都以为程序媛也个个不修边幅,但我们也许...

MySQL数据库面试题(2020最新版)

文章目录数据库基础知识为什么要使用数据库什么是SQL?什么是MySQL?数据库三大范式是什么mysql有关权限的表都有哪几个MySQL的binlog有有几种录入格式?分别有什么区别?数据类型mysql有哪些数据类型引擎MySQL存储引擎MyISAM与InnoDB区别MyISAM索引与InnoDB索引的区别?InnoDB引擎的4大特性存储引擎选择索引什么是索引?索引有哪些优缺点?索引使用场景(重点)...

如果你是老板,你会不会踢了这样的员工?

有个好朋友ZS,是技术总监,昨天问我:“有一个老下属,跟了我很多年,做事勤勤恳恳,主动性也很好。但随着公司的发展,他的进步速度,跟不上团队的步伐了,有点...

我入职阿里后,才知道原来简历这么写

私下里,有不少读者问我:“二哥,如何才能写出一份专业的技术简历呢?我总感觉自己写的简历太烂了,所以投了无数份,都石沉大海了。”说实话,我自己好多年没有写过简历了,但我认识的一个同行,他在阿里,给我说了一些他当年写简历的方法论,我感觉太牛逼了,实在是忍不住,就分享了出来,希望能够帮助到你。 01、简历的本质 作为简历的撰写者,你必须要搞清楚一点,简历的本质是什么,它就是为了来销售你的价值主张的。往深...

我说我不会算法,阿里把我挂了。

不说了,字节跳动也反手把我挂了。

优雅的替换if-else语句

场景 日常开发,if-else语句写的不少吧??当逻辑分支非常多的时候,if-else套了一层又一层,虽然业务功能倒是实现了,但是看起来是真的很不优雅,尤其是对于我这种有强迫症的程序"猿",看到这么多if-else,脑袋瓜子就嗡嗡的,总想着解锁新姿势:干掉过多的if-else!!!本文将介绍三板斧手段: 优先判断条件,条件不满足的,逻辑及时中断返回; 采用策略模式+工厂模式; 结合注解,锦...

离职半年了,老东家又发 offer,回不回?

有小伙伴问松哥这个问题,他在上海某公司,在离职了几个月后,前公司的领导联系到他,希望他能够返聘回去,他很纠结要不要回去? 俗话说好马不吃回头草,但是这个小伙伴既然感到纠结了,我觉得至少说明了两个问题:1.曾经的公司还不错;2.现在的日子也不是很如意。否则应该就不会纠结了。 老实说,松哥之前也有过类似的经历,今天就来和小伙伴们聊聊回头草到底吃不吃。 首先一个基本观点,就是离职了也没必要和老东家弄的苦...

为什么你不想学习?只想玩?人是如何一步一步废掉的

不知道是不是只有我这样子,还是你们也有过类似的经历。 上学的时候总有很多光辉历史,学年名列前茅,或者单科目大佬,但是虽然慢慢地长大了,你开始懈怠了,开始废掉了。。。 什么?你说不知道具体的情况是怎么样的? 我来告诉你: 你常常潜意识里或者心理觉得,自己真正的生活或者奋斗还没有开始。总是幻想着自己还拥有大把时间,还有无限的可能,自己还能逆风翻盘,只不是自己还没开始罢了,自己以后肯定会变得特别厉害...

男生更看重女生的身材脸蛋,还是思想?

往往,我们看不进去大段大段的逻辑。深刻的哲理,往往短而精悍,一阵见血。问:产品经理挺漂亮的,有点心动,但不知道合不合得来。男生更看重女生的身材脸蛋,还是...

为什么程序员做外包会被瞧不起?

二哥,有个事想询问下您的意见,您觉得应届生值得去外包吗?公司虽然挺大的,中xx,但待遇感觉挺低,马上要报到,挺纠结的。

当HR压你价,说你只值7K,你该怎么回答?

当HR压你价,说你只值7K时,你可以流畅地回答,记住,是流畅,不能犹豫。 礼貌地说:“7K是吗?了解了。嗯~其实我对贵司的面试官印象很好。只不过,现在我的手头上已经有一份11K的offer。来面试,主要也是自己对贵司挺有兴趣的,所以过来看看……”(未完) 这段话主要是陪HR互诈的同时,从公司兴趣,公司职员印象上,都给予对方正面的肯定,既能提升HR的好感度,又能让谈判气氛融洽,为后面的发挥留足空间。...

面试:第十六章:Java中级开发(16k)

HashMap底层实现原理,红黑树,B+树,B树的结构原理 Spring的AOP和IOC是什么?它们常见的使用场景有哪些?Spring事务,事务的属性,传播行为,数据库隔离级别 Spring和SpringMVC,MyBatis以及SpringBoot的注解分别有哪些?SpringMVC的工作原理,SpringBoot框架的优点,MyBatis框架的优点 SpringCould组件有哪些,他们...

面试阿里p7,被按在地上摩擦,鬼知道我经历了什么?

面试阿里p7被问到的问题(当时我只知道第一个):@Conditional是做什么的?@Conditional多个条件是什么逻辑关系?条件判断在什么时候执...

你打算用Java 8一辈子都不打算升级到Java 14,真香

我们程序员应该抱着尝鲜、猎奇的心态,否则就容易固步自封,技术停滞不前。

无代码时代来临,程序员如何保住饭碗?

编程语言层出不穷,从最初的机器语言到如今2500种以上的高级语言,程序员们大呼“学到头秃”。程序员一边面临编程语言不断推陈出新,一边面临由于许多代码已存在,程序员编写新应用程序时存在重复“搬砖”的现象。 无代码/低代码编程应运而生。无代码/低代码是一种创建应用的方法,它可以让开发者使用最少的编码知识来快速开发应用程序。开发者通过图形界面中,可视化建模来组装和配置应用程序。这样一来,开发者直...

面试了一个 31 岁程序员,让我有所触动,30岁以上的程序员该何去何从?

最近面试了一个31岁8年经验的程序猿,让我有点感慨,大龄程序猿该何去何从。

大三实习生,字节跳动面经分享,已拿Offer

说实话,自己的算法,我一个不会,太难了吧

程序员垃圾简历长什么样?

已经连续五年参加大厂校招、社招的技术面试工作,简历看的不下于万份 这篇文章会用实例告诉你,什么是差的程序员简历! 疫情快要结束了,各个公司也都开始春招了,作为即将红遍大江南北的新晋UP主,那当然要为小伙伴们做点事(手动狗头)。 就在公众号里公开征简历,义务帮大家看,并一一点评。《启舰:春招在即,义务帮大家看看简历吧》 一石激起千层浪,三天收到两百多封简历。 花光了两个星期的所有空闲时...

《经典算法案例》01-08:如何使用质数设计扫雷(Minesweeper)游戏

我们都玩过Windows操作系统中的经典游戏扫雷(Minesweeper),如果把质数当作一颗雷,那么,表格中红色的数字哪些是雷(质数)?您能找出多少个呢?文中用列表的方式罗列了10000以内的自然数、质数(素数),6的倍数等,方便大家观察质数的分布规律及特性,以便对算法求解有指导意义。另外,判断质数是初学算法,理解算法重要性的一个非常好的案例。

《Oracle Java SE编程自学与面试指南》最佳学习路线图(2020最新版)

正确选择比瞎努力更重要!

一文带你入门Java Stream流,太强了

两个星期以前,就有读者强烈要求我写一篇 Java Stream 流的文章,我说市面上不是已经有很多了吗,结果你猜他怎么说:“就想看你写的啊!”你看你看,多么苍白的喜欢啊。那就“勉为其难”写一篇吧,嘻嘻。 单从“Stream”这个单词上来看,它似乎和 java.io 包下的 InputStream 和 OutputStream 有些关系。实际上呢,没毛关系。Java 8 新增的 Stream 是为...

立即提问
相关内容推荐