Error message here!

Hide Error message here!

忘记密码?

Error message here!

请输入正确邮箱

Hide Error message here!

密码丢失?请输入您的电子邮件地址。您将收到一个重设密码链接。

Error message here!

返回登录

Close

Proguard 混淆的一些经验教训!!!

CanntBelieve 2020-02-29 22:55:00 阅读数:51 评论数:0 点赞数:0 收藏数:0

混淆工具 proguard 前后接触一段时间了,差不多了是明白了,不过遇到很多坑,差点被跳不出来坑了!真的难学啊! 真是是太难了;

 

教训1  ServerKeyStore 是kotlin类,不能 进行普通的混淆。 

-- ::, [ERROR] PCStarter: - Unable to start server. biz.lk.pcng.server.ServerKeyStore$a.invoke()Ljava/lang/Object; [main]
java.lang.AbstractMethodError: ...server.ServerKeyStore$a.invoke()Ljava/lang/Object;
at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:)
at ...server.ServerKeyStore.getCertAlias(ServerKeyStore.kt)
at ...server.web.Jetty.c(Jetty.java)
at ...server.web.Jetty.c(Jetty.java)
at ...server.web.Jetty.a(Jetty.java)
at ...server.web.Jetty.a(Jetty.java)
at ...server.web.EmbeddedServer.start(EmbeddedServer.java)
at com.lk.PCStarter.startWebServer(PCStarter.java:)
at com.lk.PCStarter.start(PCStarter.java:)
at com.lk.PCStarter.start000(PCStarter.java:)
at com.lk.PCStarter.main(PCStarter.java:)
Disconnected from the target VM, address: '127.0.0.1:44519', transport: 'socket'

原因分析:反编译可以看到ServerKeyStore 的很多信息丢失了,被变成了java 类,但是人家本来就不是java类; 而且kotlin 的一下特有的注解 也不见了;

解决方案:需要保留kotlin 特性 

 

教训2   匿名内部类,被重命名了为a、b、c之类,方法的实现、继承全部失效,而且不抛错误!

org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type '...service.ConfigManager' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}

-- ::, [ERROR] ContextLoader: - Context initialization failed [main]
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'tipsConfiguration' defined in file [C:\Users\admin\IdeaProjects\lk\out\production\lk3\biz\lk\pcng\web\TipsConfiguration.class]: Unsatisfied dependency expressed through constructor parameter ; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type '...service.ConfigManager' available: expected at least bean which qualifies as autowire candidate. Dependency annotations: {}
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:)
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:)
at org.springframework.beans.factory.support.AbstractBeanFactory$.getObject(AbstractBeanFactory.java:)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:)
at org.eclipse.jetty.server.handler.ContextHandler.callContextInitialized(ContextHandler.java:)
at org.eclipse.jetty.servlet.ServletContextHandler.callContextInitialized(ServletContextHandler.java:)
at org.eclipse.jetty.server.handler.ContextHandler.startContext(ContextHandler.java:)
at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:)
at org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:)
at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:)
at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:)
at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:)
at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:)
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:)
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:)
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:)
at org.eclipse.jetty.server.handler.gzip.GzipHandler.doStart(GzipHandler.java:)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:)
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:)
at org.eclipse.jetty.server.handler.StatisticsHandler.doStart(StatisticsHandler.java:)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:)
at org.eclipse.jetty.server.Server.start(Server.java:)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:)
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:)
at org.eclipse.jetty.server.Server.doStart(Server.java:)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:)
at ...server.web.EmbeddedServer.start(EmbeddedServer.java:)
at com.lk.PCStarter.startWebServer(PCStarter.java:)
at com.lk.PCStarter.start(PCStarter.java:)
at com.lk.PCStarter.start000(PCStarter.java:)
at com.lk.PCStarter.main(PCStarter.java:)
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type '...service.ConfigManager' available: expected at least bean which qualifies as autowire candidate. Dependency annotations: {}
at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:)
at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:)
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:)
...  more
-- ::, [WARN ] WebAppContext: - Failed startup of context o.e.j.w.WebAppContext@f90849{lk,/,file:/C:/Users/admin/IdeaProjects/lk/web/,UNAVAILABLE}{./web} [main]
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'tipsConfiguration' defined in file [C:\Users\admin\IdeaProjects\lk\out\production\lk3\biz\lk\pcng\web\TipsConfiguration.class]: Unsatisfied dependency expressed through constructor parameter ; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type '...service.ConfigManager' available: expected at least bean which qualifies as autowire candidate. Dependency annotations: {}
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:)
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:)
at org.springframework.beans.factory.support.AbstractBeanFactory$.getObject(AbstractBeanFactory.java:)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:)
at org.eclipse.jetty.server.handler.ContextHandler.callContextInitialized(ContextHandler.java:)
at org.eclipse.jetty.servlet.ServletContextHandler.callContextInitialized(ServletContextHandler.java:)
at org.eclipse.jetty.server.handler.ContextHandler.startContext(ContextHandler.java:)
at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:)
at org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:)
at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:)
at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:)
at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:)
at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:)
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:)
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:)
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:)
at org.eclipse.jetty.server.handler.gzip.GzipHandler.doStart(GzipHandler.java:)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:)
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:)
at org.eclipse.jetty.server.handler.StatisticsHandler.doStart(StatisticsHandler.java:)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:)
at org.eclipse.jetty.server.Server.start(Server.java:)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:)
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:)
at org.eclipse.jetty.server.Server.doStart(Server.java:)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:)
at ...server.web.EmbeddedServer.start(EmbeddedServer.java:)
at com.lk.PCStarter.startWebServer(PCStarter.java:)
at com.lk.PCStarter.start(PCStarter.java:)
at com.lk.PCStarter.start000(PCStarter.java:)
at com.lk.PCStarter.main(PCStarter.java:)
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type '...service.ConfigManager' available: expected at least bean which qualifies as autowire candidate. Dependency annotations: {}
at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:)
at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:)
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:)
...  more
-- ::, [ERROR] PCStarter: - Error occurred starting server. Start error server. [main]
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'tipsConfiguration' defined in file [C:\Users\admin\IdeaProjects\lk\out\production\lk3\biz\lk\pcng\web\TipsConfiguration.class]: Unsatisfied dependency expressed through constructor parameter ; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type '...service.ConfigManager' available: expected at least bean which qualifies as autowire candidate. Dependency annotations: {}
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:)
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:)
View Code

原因分析:因为它不是public 类,本来需要一个, 结果找不到,因为混淆之后,某些package 没有被扫描到! 混淆之后 原来继承jetty框架的类, 因为是内部类,被重命名了为a、b、c之类的导致 相当于没有继承,从而没有执行,从而导致了 严重问题!

解决方案:需要保留某些内部匿名类、非public内等

 

教训3  private 方法,混淆之后被重命名,hibernate 反射访问出错:

 Could not find a setter for property groupLinks in class ...domain.User

-- ::, [DEBUG] DataSourceConfig: - Creating primary datasource router for main: org.springframework.jdbc.datasource.IsolationLevelDataSourceAdapter@1ea9f02, secondary: org.springframework.jdbc.datasource.IsolationLevelDataSourceAdapter@18cb7c6 [main]
-- ::, [ERROR] ContextLoader: - Context initialization failed [main]
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'tipsConfiguration' defined in file [C:\Users\admin\IdeaProjects\lk\out\production\lk3\biz\lk\pcng\web\TipsConfiguration.class]: Unsatisfied dependency expressed through constructor parameter ; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'configManager' defined in URL [jar:file:/D:/dev/svn_new/trunk/pc-webserver/server/lib/pcng-server-18.3..jar!/biz/lk/pcng/service/impl/ConfigManagerImpl.class]: Unsatisfied dependency expressed through constructor parameter ; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'configPropertyDAO' defined in class path resource [biz/lk/pcng/persistence/hibernate/applicationContext-hibernate.xml]: Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [biz/lk/pcng/persistence/hibernate/applicationContext-hibernate.xml]: Invocation of init method failed; nested exception is org.hibernate.HibernateException: Unable to instantiate default tuplizer [org.hibernate.tuple.entity.PojoEntityTuplizer]
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:)
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:)
at org.springframework.beans.factory.support.AbstractBeanFactory$.getObject(AbstractBeanFactory.java:)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:)
at org.eclipse.jetty.server.handler.ContextHandler.callContextInitialized(ContextHandler.java:)
at org.eclipse.jetty.servlet.ServletContextHandler.callContextInitialized(ServletContextHandler.java:)
at org.eclipse.jetty.server.handler.ContextHandler.startContext(ContextHandler.java:)
at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:)
at org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:)
at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:)
at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:)
at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:)
at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:)
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:)
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:)
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:)
at org.eclipse.jetty.server.handler.gzip.GzipHandler.doStart(GzipHandler.java:)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:)
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:)
at org.eclipse.jetty.server.handler.StatisticsHandler.doStart(StatisticsHandler.java:)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:)
at org.eclipse.jetty.server.Server.start(Server.java:)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:)
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:)
at org.eclipse.jetty.server.Server.doStart(Server.java:)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:)
at ...server.web.EmbeddedServer.start(EmbeddedServer.java:)
at com.lk.PCStarter.startWebServer(PCStarter.java:)
at com.lk.PCStarter.start(PCStarter.java:)
at com.lk.PCStarter.start000(PCStarter.java:)
at com.lk.PCStarter.main(PCStarter.java:)
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'configManager' defined in URL [jar:file:/D:/dev/svn_new/trunk/pc-webserver/server/lib/pcng-server-18.3..jar!/biz/lk/pcng/service/impl/ConfigManagerImpl.class]: Unsatisfied dependency expressed through constructor parameter ; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'configPropertyDAO' defined in class path resource [biz/lk/pcng/persistence/hibernate/applicationContext-hibernate.xml]: Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [biz/lk/pcng/persistence/hibernate/applicationContext-hibernate.xml]: Invocation of init method failed; nested exception is org.hibernate.HibernateException: Unable to instantiate default tuplizer [org.hibernate.tuple.entity.PojoEntityTuplizer]
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:)
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:)
at org.springframework.beans.factory.support.AbstractBeanFactory$.getObject(AbstractBeanFactory.java:)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:)
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:)
at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:)
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:)
...  more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'configPropertyDAO' defined in class path resource [biz/lk/pcng/persistence/hibernate/applicationContext-hibernate.xml]: Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [biz/lk/pcng/persistence/hibernate/applicationContext-hibernate.xml]: Invocation of init method failed; nested exception is org.hibernate.HibernateException: Unable to instantiate default tuplizer [org.hibernate.tuple.entity.PojoEntityTuplizer]
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:)
at org.springframework.beans.factory.support.AbstractBeanFactory$.getObject(AbstractBeanFactory.java:)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:)
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:)
at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:)
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:)
...  more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [biz/lk/pcng/persistence/hibernate/applicationContext-hibernate.xml]: Invocation of init method failed; nested exception is org.hibernate.HibernateException: Unable to instantiate default tuplizer [org.hibernate.tuple.entity.PojoEntityTuplizer]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:)
at org.springframework.beans.factory.support.AbstractBeanFactory$.getObject(AbstractBeanFactory.java:)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:)
...  more
Caused by: org.hibernate.HibernateException: Unable to instantiate default tuplizer [org.hibernate.tuple.entity.PojoEntityTuplizer]
at org.hibernate.tuple.entity.EntityTuplizerFactory.constructTuplizer(EntityTuplizerFactory.java:)
at org.hibernate.tuple.entity.EntityTuplizerFactory.constructDefaultTuplizer(EntityTuplizerFactory.java:)
at org.hibernate.tuple.entity.EntityEntityModeToTuplizerMapping.<init>(EntityEntityModeToTuplizerMapping.java:)
at org.hibernate.tuple.entity.EntityMetamodel.<init>(EntityMetamodel.java:)
at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:)
at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:)
at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:)
at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:)
...  more
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:)
at java.lang.reflect.Constructor.newInstance(Constructor.java:)
at org.hibernate.tuple.entity.EntityTuplizerFactory.constructTuplizer(EntityTuplizerFactory.java:)
...  more
Caused by: org.hibernate.PropertyNotFoundException: Could not find a setter for property groupLinks in class ...domain.User
at org.hibernate.property.BasicPropertyAccessor.createSetter(BasicPropertyAccessor.java:)
at org.hibernate.property.BasicPropertyAccessor.getSetter(BasicPropertyAccessor.java:)
at org.hibernate.mapping.Property.getSetter(Property.java:)
at org.hibernate.tuple.entity.PojoEntityTuplizer.buildPropertySetter(PojoEntityTuplizer.java:)
at org.hibernate.tuple.entity.AbstractEntityTuplizer.<init>(AbstractEntityTuplizer.java:)
at org.hibernate.tuple.entity.PojoEntityTuplizer.<init>(PojoEntityTuplizer.java:)
...  more
View Code

原因分析:本来需要一个 setGroupLinks, 结果因为 setGroupLinks 是 private 方法,混淆之后被重命名..  ———— 没想到 hibernate需要对 private 方法进行反射, 实在没想到。

解决方案:需要保留persistent层 hibernate用到的一些 domain 类 的private  属性

 

教训4 无法进行转换: Cannot convert value of type '...$$..' to required type '...'


Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'synchronisationManager' defined in class path resource [biz/lk/pcng/service/applicationContext-service.xml]: Cannot resolve reference to bean 'userManager' while setting bean property 'userManager'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userManager' defined in class path resource [biz/lk/pcng/service/applicationContext-service.xml]: Unsatisfied dependency expressed through constructor parameter : Could not convert argument value of type [...service.impl.AccountManagerImpl$$EnhancerBySpringCGLIB$$9dcff66f] to required type [...persistence.UserDAO]: Failed to convert value of type '...service.impl.AccountManagerImpl$$EnhancerBySpringCGLIB$$9dcff66f' to required type '...persistence.UserDAO'; nested exception is java.lang.IllegalStateException: Cannot convert value of type '...service.impl.AccountManagerImpl$$EnhancerBySpringCGLIB$$9dcff66f' to required type '...persistence.UserDAO': no matching editors or conversion strategy found

 

-- ::, [WARN ] WebAppContext: - Failed startup of context o.e.j.w.WebAppContext@f90849{lk,/,file:/C:/Users/admin/IdeaProjects/lk/web/,UNAVAILABLE}{./web} [main]
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userSourceUtils' defined in file [C:\Users\admin\IdeaProjects\lk\out\production\lk3\biz\lk\pcng\web\util\UserSourceUtils.class]: Unsatisfied dependency expressed through constructor parameter ; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'synchronisationManager' defined in class path resource [biz/lk/pcng/service/applicationContext-service.xml]: Cannot resolve reference to bean 'userManager' while setting bean property 'userManager'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userManager' defined in class path resource [biz/lk/pcng/service/applicationContext-service.xml]: Unsatisfied dependency expressed through constructor parameter : Could not convert argument value of type [...service.impl.AccountManagerImpl$$EnhancerBySpringCGLIB$$a4971023] to required type [...persistence.UserDAO]: Failed to convert value of type '...service.impl.AccountManagerImpl$$EnhancerBySpringCGLIB$$a4971023' to required type '...persistence.UserDAO'; nested exception is java.lang.IllegalStateException: Cannot convert value of type '...service.impl.AccountManagerImpl$$EnhancerBySpringCGLIB$$a4971023' to required type '...persistence.UserDAO': no matching editors or conversion strategy found
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:)
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:)
at org.springframework.beans.factory.support.AbstractBeanFactory$.getObject(AbstractBeanFactory.java:)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:)
at org.eclipse.jetty.server.handler.ContextHandler.callContextInitialized(ContextHandler.java:)
at org.eclipse.jetty.servlet.ServletContextHandler.callContextInitialized(ServletContextHandler.java:)
at org.eclipse.jetty.server.handler.ContextHandler.startContext(ContextHandler.java:)
at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:)
at org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:)
at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:)
at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:)
at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:)
at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:)
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:)
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:)
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:)
at org.eclipse.jetty.server.handler.gzip.GzipHandler.doStart(GzipHandler.java:)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:)
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:)
at org.eclipse.jetty.server.handler.StatisticsHandler.doStart(StatisticsHandler.java:)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:)
at org.eclipse.jetty.server.Server.start(Server.java:)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:)
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:)
at org.eclipse.jetty.server.Server.doStart(Server.java:)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:)
at ...server.web.EmbeddedServer.start(EmbeddedServer.java)
at com.lk.PCStarter.startWebServer(PCStarter.java:)
at com.lk.PCStarter.start(PCStarter.java:)
at com.lk.PCStarter.start000(PCStarter.java:)
at com.lk.PCStarter.main(PCStarter.java:)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'synchronisationManager' defined in class path resource [biz/lk/pcng/service/applicationContext-service.xml]: Cannot resolve reference to bean 'userManager' while setting bean property 'userManager'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userManager' defined in class path resource [biz/lk/pcng/service/applicationContext-service.xml]: Unsatisfied dependency expressed through constructor parameter : Could not convert argument value of type [...service.impl.AccountManagerImpl$$EnhancerBySpringCGLIB$$a4971023] to required type [...persistence.UserDAO]: Failed to convert value of type '...service.impl.AccountManagerImpl$$EnhancerBySpringCGLIB$$a4971023' to required type '...persistence.UserDAO'; nested exception is java.lang.IllegalStateException: Cannot convert value of type '...service.impl.AccountManagerImpl$$EnhancerBySpringCGLIB$$a4971023' to required type '...persistence.UserDAO': no matching editors or conversion strategy found
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:)
at org.springframework.beans.factory.support.AbstractBeanFactory$.getObject(AbstractBeanFactory.java:)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:)
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:)
at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:)
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:)
...  more
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userManager' defined in class path resource [biz/lk/pcng/service/applicationContext-service.xml]: Unsatisfied dependency expressed through constructor parameter : Could not convert argument value of type [...service.impl.AccountManagerImpl$$EnhancerBySpringCGLIB$$a4971023] to required type [...persistence.UserDAO]: Failed to convert value of type '...service.impl.AccountManagerImpl$$EnhancerBySpringCGLIB$$a4971023' to required type '...persistence.UserDAO'; nested exception is java.lang.IllegalStateException: Cannot convert value of type '...service.impl.AccountManagerImpl$$EnhancerBySpringCGLIB$$a4971023' to required type '...persistence.UserDAO': no matching editors or conversion strategy found
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:)
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:)
at org.springframework.beans.factory.support.AbstractBeanFactory$.getObject(AbstractBeanFactory.java:)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:)
...  more
View Code

原因分析:注意看,错误是 : Cannot convert value of type '...service.impl.AccountManagerImpl$$..' to required type '...persistence.UserDAO, 简直不可思议, 为什么会进行 AccountManagerImpl 和 UserDAO 的转换? 猜测是因为 userManager 的构造器有多个参数, 混淆之后 参数名字丢失, 无法 根据applicationContext-service.xml进行名字的设定,所以出现了这等奇怪问题;

解决方案:  UserManager 及 UserManagerImpl 等service类不进行任何的混淆.. 暂时只能这样。

 

教训4  需一个类, 结果却有多个:

biz.papercut.pcng.server.config.CommonConfig#propertyConfigurer

@ImportResource(
locations = {"classpath:/applicationContext-main.xml", "classpath:/biz/papercut/pcng/persistence/hibernate/applicationContext-hibernate.xml", "classpath:/biz/papercut/pcng/service/applicationContext-service.xml", "classpath:/biz/papercut/pcng/webservices/xmlrpc/applicationContext-xmlrpc.xml", "classpath*:/com/papercut/device/web/**/applicationContext-device-web-*.xml"}
)
@Configuration
public class CommonConfig {
public CommonConfig() {
}
@Bean
public ServerConfig bootstrapConfig() {
return ServerConfig.getInstance();
}
@Bean
public Properties bootstrapProperties(ServerConfig serverConfig) {
return serverConfig.getAllProperties();
}
@Bean
public PropertySourcesPlaceholderConfigurer propertyConfigurer(Properties bootstrapProperties) {
PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer = new PropertySourcesPlaceholderConfigurer();
propertySourcesPlaceholderConfigurer.setProperties(bootstrapProperties);
propertySourcesPlaceholderConfigurer.setIgnoreResourceNotFound(true);
propertySourcesPlaceholderConfigurer.setIgnoreUnresolvablePlaceholders(true);
return propertySourcesPlaceholderConfigurer;
}
}

propertyConfigurer 方法需要一个 Properties , 结果发现有多个:

 

 

 

原因分析:反编译可以看到 propertyConfigurer 方法的参数名字已经丢失了,不知道为什么, 本来应该是 bootstrapProperties, 结果却..   猜测是 不能通过name进行自动注入,于是只能通过type,但是可选的 type有多个, 故出现错误..

解决方案: 保留必要的方法签名, 包括名字、参数

 

...

 

我的配置参考:

-injars 'C:\Users\admin\IdeaProjects\test\out\production\test3'
-outjars 'D:\dev\svn_new\测试\test-lk-3.0.2.852741.jar'
-libraryjars 'C:\Program Files (x86)\Java\jdk1.8.0_121\jre\lib\rt.jar'
-skipnonpubliclibraryclasses
-forceprocessing
-dontshrink
-dontoptimize
-keepattributes Exceptions,InnerClasses,Signature,Deprecated,SourceFile,*Annotation*,Synthetic,EnclosingMethod
-verbose
-dontnote
-dontwarn
-dontpreverify
# -dontobfuscate
# -dontwarn kotlin.**// 同一个dontwarn 指定多次,以后者为准...  -dontwarn kotlin 的意思是 kotlin目录下的类 不warn, 但是其他的 还是需要的!! 非常容易混淆!
-keep,allowshrinking class * {
!private <fields>;
!private <methods>;
}
# Also keep - Enumerations. Keep the special static methods that are required in
# enumeration classes.
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keep class kotlin.** { *; }
-keep class kotlin.Metadata { *; }
-keepclassmembers class **$WhenMappings {
<fields>;
}
-keepclassmembers class kotlin.Metadata { *; }
-keep @kotlin.Metadata class *
-keepclasseswithmembers @kotlin.Metadata class * { *; }
-assumenosideeffects class kotlin.jvm.internal.Intrinsics {
static void checkParameterIsNotNull(java.lang.Object, java.lang.String);
}
-keepclassmembers class **$** {
*;
}
-keepclasseswithmembers class **$** {
*;
}
-keep class biz.papercut.pcng.domain.** { *; }
-keep class biz.papercut.pcng.service.** { *; }
-keep class biz.papercut.pcng.persistence.** { *; }
-keep class biz.papercut.pcng.server.config.** { *; }
-keep @org.springframework.stereotype.Service class *
-keep @org.springframework.context.annotation.Configuration class * { *; }
# -keepclassmembers public class * {void set*(***);*** get*();}

 

注意 

dontwarn不能出现多次, 否则以后者为准 ,忽视前面的, Proguard 这个配置 非常蛋疼, 一不小心结果面目全非。

 

 

 

 

 

 

 

 

org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type '...service.ConfigManager' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}

版权声明
本文为[CanntBelieve]所创,转载请带上原文链接,感谢
https://www.cnblogs.com/FlyAway2013/p/12386822.html