异常信息1:
解决:
--------------------------------------------------------------------
异常信息2:
解决:
org.springframework.aop.framework.AopConfigException: Cannot proxy target class because CGLIB2 is not available. Add CGLIB to the class path or specify proxy interfaces.
org.springframework.aop.framework.DefaultAopProxyFactory.createAopProxy(DefaultAopProxyFactory.java:67)
org.springframework.aop.framework.ProxyCreatorSupport.createAopProxy(ProxyCreatorSupport.java:106)
org.springframework.aop.framework.ProxyFactory.getProxy(ProxyFactory.java:110)
解决:
由于CGLIB基于字节码的静态代理不能建立,缺少jar包:cglib-nodep-2.2.jar
--------------------------------------------------------------------
异常信息2:
Caused by: org.hibernate.MappingException: could not instantiate id generator [entity-name=cn.aa.test.entity.User2]
at org.hibernate.id.IdentifierGeneratorFactory.create(IdentifierGeneratorFactory.java:132)
at org.hibernate.mapping.SimpleValue.createIdentifierGenerator(SimpleValue.java:175)
。。。。。。
Caused by: org.hibernate.MappingException: Dialect does not support sequences
at org.hibernate.dialect.Dialect.getSequenceNextValString(Dialect.java:619)
at org.hibernate.id.SequenceGenerator.configure(SequenceGenerator.java:88)
。。。。。。
解决:
此处是用的mysql数据库,该表主键设置为auto_increment,
修改该对象主键生成策略名称为:
@GeneratedValue(strategy = GenerationType.IDENTITY)即可。
若数据库为oracle,则修改为@GeneratedValue(strategy = GenerationType.SEQUENCE)
本文解决两个常见问题:一是Spring AOP配置异常,提示无法为类创建代理,解决方案是添加CGLIB依赖;二是Hibernate在使用MySQL数据库时出现主键生成错误,通过调整实体类主键生成策略解决。
117

被折叠的 条评论
为什么被折叠?



