spring bean prototype 配置不起作用

框架 struts2+spring,我有一个登录的vo,里面放用户的登录信息,
当第一个用户登录后,第二个用户再登录将第一个用户的信息冲掉,第一个登录的账号
刷新后成了第二个登陆者的信息。
使用的是spring的bean,配置如下:
bean的配置
##

  <bean id="userLoginInfo" class="com.user.vo.UserLoginInfo" scope="prototype"/>

action的配置:

 <bean id="userAction" class="com.yljy.user.action.UserAction">
        <property name="userLoginInfo" ref="userLoginInfo"/>
    </bean>
实在不知道错在哪了,明显已经配置了scope="prototype" ,为什么就是不起作用,求解答,谢谢。

4个回答

你可以自己验证下下,打个断点,输出userLoginInfo的地址值 ,比较两次的内存地址值就可以知道到底有没有起作用了。如果不一样,那肯定不是它的原因 了

sssbbbryj
狼族_RYJ 我没输出,但是它肯定是在内容中将userLoginInfo这个共享了
接近 5 年之前 回复
sssbbbryj
狼族_RYJ 我没输出,但是它肯定是在内容中将userLoginInfo这个共享了
接近 5 年之前 回复

你的意思是你用第二个人登陆,可是显示登陆的却是两个人???

sssbbbryj
狼族_RYJ 我的意思是第二个人登陆后,第一个人刷新自己的页面,将显示第二个人的信息
接近 5 年之前 回复

action应该也设置为yuanxing
吧?

u013114174
DO IT scope="prototype"
接近 5 年之前 回复
sssbbbryj
狼族_RYJ 什么yuanxing ?什么意思?
接近 5 年之前 回复
u013114174
DO IT 原型
接近 5 年之前 回复

action 设置成prototype

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

<span style="font-size: medium;">我们知道,spring有singleton和prototype作用域,而且从spring2.0开始,又增加了三种作用域,request、session、global session。session、global session的作用域是HTTP session和全局session。对于request和prototype,每一次请求都会产生一个新的bean实例,那么它们的具体有什么区别呢?而且,Spring不能对一个prototype bean的整个生命周期负责,这一点我不太能理解,这样它占用的资源就很高昂了,那么prototype的好处是什么?要结束它的生命周围,要怎么做?而且,感觉request和prototype,除了prototype的生命周期不会被回调以外,它们的作用是不是一样?有什么具体的区别呢?</span>

关于Spring2.0中bean的作用域为prototype时容器的回收问题

总所周知,当spring容器中管理bean属性为singleton时,spring容器会管理该bean整个生命周期。 当bean的作用域为prototype时,每次调用到该bean都相当于重新new了一次,那么该bean的生命周期将由谁负责管理,JVM自动回收么?还是需要自己在哪写代码负责后续回收?

关于spring bean销毁的问题

今天在熟悉spring bean的生命周期时发现bean的作用域定义为prototype时,通过((AbstractApplicationContext) context).registerShutdownHook()方法不能销毁,尝试用close方法也不能销毁,那么通过什么方法可以销毁呢? ``` HelloWorld helloWorld5 = (HelloWorld) context.getBean("helloworld"); helloWorld5.getMessage(); //((AbstractApplicationContext) context).registerShutdownHook(); ((AbstractApplicationContext) context).close(); ```

spring 清除scope="prototype"的Bean

现在我的项目是基于struts2+spring2.0+hibernate3 在Spring配置时将Action的Scpoe配置成prototype,因为Action对象的创建是由Struts2委托给Spring的,这将导致Spring为每个请求都创建一个ActionBean。而我看到很多博客里都这么写,要把Action配置成prototype。 但问题是,我在看spring文档是,看到这一句话[color=red]“清除prototype作用域的对象并释放任何prototype bean所持有的昂贵资源,都是客户端代码的职责。”[/color] 我就想问一下,什么叫“[color=red]清除prototype作用域的对象并释放任何prototype bean所持有的昂贵资源[/color]”?我又怎样在客户端代码完成清除prototype作用域的对象并释放任何prototype bean所持有的昂贵资源? 希望大家能为我答疑解惑

Spring bean注入 获取为空

<!--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" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"> <property name="driverClassName" value="com.mysql.jdbc.Driver"> </property> <property name="url" value="jdbc:mysql://localhost:3306/db_xyd?useUnicode=true&amp;amp;amp;amp;amp;amp;characterEncoding=utf-8-"> </property> <property name="username" value="root"></property> <property name="password" value="1234"></property> </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource"> <ref bean="dataSource" /> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect"> <!-- org.hibernate.dialect.SQLServerDialect--> org.hibernate.dialect.MySQLDialect </prop> <prop key="hibernate.show_sql">true</prop> </props> </property> <property name="mappingResources"> <list> <value>com/model/TDictionary.hbm.xml</value> </list> </property> </bean> <!-- dictionary --> <bean id="TDictionaryDAO" class="com.dao.TDictionaryDAO"> <property name="sessionFactory"> <ref bean="sessionFactory" /> </property> </bean> <bean id="dictionaryAction" class="com.action.dictionaryAction" scope="prototype"> <property name="dictionaryDAO"> <ref bean="TDictionaryDAO" /> </property> </bean> </beans> package com.dao; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.context.ApplicationContext; import org.springframework.orm.hibernate3.support.HibernateDaoSupport; import com.model.TDictionary; public class TDictionaryDAO extends HibernateDaoSupport { private static final Log log = LogFactory.getLog(TDictionaryDAO.class); public void save(TDictionary transientInstance) { log.debug("saving TDictionary instance"); try { getHibernateTemplate().save(transientInstance); log.debug("save successful"); } catch (RuntimeException re) { log.error("save failed", re); throw re; } } public static TDictionaryDAO getFromApplicationContext(ApplicationContext ctx) { return (TDictionaryDAO) ctx.getBean("TDictionaryDAO"); } } package com.action; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.context.support.FileSystemXmlApplicationContext; import com.dao.TDictionaryDAO; import com.model.TDictionary; import com.opensymphony.xwork2.ActionSupport; public class dictionaryAction extends ActionSupport { private int OID; private String willtake; private TDictionaryDAO dictionaryDAO; public String dictionaryAdd() { TDictionary dict=new TDictionary(); dict.setOID(OID); dict.setL_key(100000); dict.setVc_value(willtake); dict.setVc_caption("vc_caption"); //这里报空指针异常,是dictionaryDAO空 dictionaryDAO.save(dict); return "success"; } public TDictionaryDAO getDictionaryDAO() { return dictionaryDAO; } public void setDictionaryDAO(TDictionaryDAO dictionaryDAO) { this.dictionaryDAO = dictionaryDAO; } }

为什么我配置Spring的事务后不能得到BEAN

我配置Spring的事务后不能得到BEAN 如果把事务的部分去掉的话就能够得到 下面这是applicationContext.xml [code="xml"] <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd "> <bean id="myDataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName" value="net.sourceforge.jtds.jdbc.Driver"></property> <property name="url" value="jdbc:jtds:sqlserver://localhost:1433/soft2005"></property> <property name="username" value="sa"></property> <property name="password" value=""></property> </bean> <bean id="SessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource" ref="myDataSource"></property> <property name="mappingResources"> <list> <value>com/yhwj/secsms/po/Cgnx.hbm.xml</value> </list> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect"> org.hibernate.dialect.SybaseDialect </prop> </props> </property> </bean> <bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="SessionFactory"></property> </bean> <tx:advice id="myadvice" transaction-manager="txManager"> <tx:attributes> <tx:method name="*" /> </tx:attributes> </tx:advice> <aop:config> <!-- <aop:pointcut id="myPoin" expression="execution(* com.yhwj.secsms.dao.CgnxDAO.*(..))"/> <aop:advisor id="myAdvi" advice-ref="myadvice" pointcut-ref="myPoin"/> --> <aop:advisor pointcut="execution(* com.yhwj.secsms.dao.CgnxDAO.*(..))" advice-ref="myadvice"/> </aop:config> <bean id="CgnxDAO" class="com.yhwj.secsms.dao.CgnxDAO"> <property name="sessionFactory"> <ref bean="SessionFactory" /> </property> </bean></beans> [/code] 下面是测试类cgnxTest.java [code="java"] package com.yhwj.secsms.bo; import java.util.Iterator; import java.util.List; import org.springframework.context.ApplicationContext; import org.springframework.context.support.FileSystemXmlApplicationContext; import com.yhwj.secsms.dao.CgnxDAO; import com.yhwj.secsms.po.Cgnx; import junit.framework.TestCase; public class cgnxTest extends TestCase { ApplicationContext ac=new FileSystemXmlApplicationContext("src/applicationContext.xml"); public void testCgnxAddFind() { CgnxDAO cdao=(CgnxDAO) ac.getBean("CgnxDAO"); com.yhwj.secsms.vo.Cgnx cg=new com.yhwj.secsms.vo.Cgnx(); cg.setCgnx("12年"); Cgnx cg1=(Cgnx) cg.getPO(); cdao.save(cg1); List l=cdao.findAll(); assertTrue(l.size()>0); } } [/code] 下面的是运行后LOG4J抓的东西 INFO - Refreshing org.springframework.context.support.FileSystemXmlApplicationContext@8f4fb3: display name [org.springframework.context.support.FileSystemXmlApplicationContext@8f4fb3]; startup date [Wed Jul 02 09:09:49 CST 2008]; root of context hierarchy DEBUG - Class [org.apache.commons.collections.map.LinkedMap] or one of its dependencies is not present: java.lang.ClassNotFoundException: org.apache.commons.collections.map.LinkedMap DEBUG - Creating [java.util.concurrent.ConcurrentHashMap] DEBUG - Creating [java.util.LinkedHashSet] DEBUG - Creating [java.util.LinkedHashMap] DEBUG - Creating [java.util.LinkedHashSet] DEBUG - Creating [java.util.concurrent.ConcurrentHashMap] DEBUG - Creating [java.util.concurrent.ConcurrentHashMap] DEBUG - Loading schema mappings from [META-INF/spring.schemas] DEBUG - Loaded schema mappings: {http://www.springframework.org/schema/aop/spring-aop-2.0.xsd=org/springframework/aop/config/spring-aop-2.0.xsd, http://www.springframework.org/schema/util/spring-util.xsd=org/springframework/beans/factory/xml/spring-util-2.0.xsd, http://www.springframework.org/schema/util/spring-util-2.0.xsd=org/springframework/beans/factory/xml/spring-util-2.0.xsd, http://www.springframework.org/schema/jee/spring-jee.xsd=org/springframework/ejb/config/spring-jee-2.0.xsd, http://www.springframework.org/schema/beans/spring-beans.xsd=org/springframework/beans/factory/xml/spring-beans-2.0.xsd, http://www.springframework.org/schema/lang/spring-lang-2.0.xsd=org/springframework/scripting/config/spring-lang-2.0.xsd, http://www.springframework.org/schema/tx/spring-tx-2.0.xsd=org/springframework/transaction/config/spring-tx-2.0.xsd, http://www.springframework.org/schema/lang/spring-lang.xsd=org/springframework/scripting/config/spring-lang-2.0.xsd, http://www.springframework.org/schema/tool/spring-tool.xsd=org/springframework/beans/factory/xml/spring-tool-2.0.xsd, http://www.springframework.org/schema/aop/spring-aop.xsd=org/springframework/aop/config/spring-aop-2.0.xsd, http://www.springframework.org/schema/tx/spring-tx.xsd=org/springframework/transaction/config/spring-tx-2.0.xsd, http://www.springframework.org/schema/tool/spring-tool-2.0.xsd=org/springframework/beans/factory/xml/spring-tool-2.0.xsd, http://www.springframework.org/schema/jee/spring-jee-2.0.xsd=org/springframework/ejb/config/spring-jee-2.0.xsd, http://www.springframework.org/schema/beans/spring-beans-2.0.xsd=org/springframework/beans/factory/xml/spring-beans-2.0.xsd} DEBUG - Loading schema mappings from [META-INF/spring.schemas] DEBUG - Loaded schema mappings: {http://www.springframework.org/schema/aop/spring-aop-2.0.xsd=org/springframework/aop/config/spring-aop-2.0.xsd, http://www.springframework.org/schema/util/spring-util.xsd=org/springframework/beans/factory/xml/spring-util-2.0.xsd, http://www.springframework.org/schema/util/spring-util-2.0.xsd=org/springframework/beans/factory/xml/spring-util-2.0.xsd, http://www.springframework.org/schema/jee/spring-jee.xsd=org/springframework/ejb/config/spring-jee-2.0.xsd, http://www.springframework.org/schema/beans/spring-beans.xsd=org/springframework/beans/factory/xml/spring-beans-2.0.xsd, http://www.springframework.org/schema/lang/spring-lang-2.0.xsd=org/springframework/scripting/config/spring-lang-2.0.xsd, http://www.springframework.org/schema/tx/spring-tx-2.0.xsd=org/springframework/transaction/config/spring-tx-2.0.xsd, http://www.springframework.org/schema/lang/spring-lang.xsd=org/springframework/scripting/config/spring-lang-2.0.xsd, http://www.springframework.org/schema/tool/spring-tool.xsd=org/springframework/beans/factory/xml/spring-tool-2.0.xsd, http://www.springframework.org/schema/aop/spring-aop.xsd=org/springframework/aop/config/spring-aop-2.0.xsd, http://www.springframework.org/schema/tx/spring-tx.xsd=org/springframework/transaction/config/spring-tx-2.0.xsd, http://www.springframework.org/schema/tool/spring-tool-2.0.xsd=org/springframework/beans/factory/xml/spring-tool-2.0.xsd, http://www.springframework.org/schema/jee/spring-jee-2.0.xsd=org/springframework/ejb/config/spring-jee-2.0.xsd, http://www.springframework.org/schema/beans/spring-beans-2.0.xsd=org/springframework/beans/factory/xml/spring-beans-2.0.xsd} INFO - Loading XML bean definitions from file [F:\自助设备客户服务管理系统\工程\src\applicationContext.xml] DEBUG - Using JAXP provider [org.apache.xerces.jaxp.DocumentBuilderFactoryImpl] DEBUG - Trying to resolve XML entity with public id [null] and system id [http://www.springframework.org/schema/beans/spring-beans-2.0.xsd] DEBUG - Found XML schema [http://www.springframework.org/schema/beans/spring-beans-2.0.xsd] in classpath: org/springframework/beans/factory/xml/spring-beans-2.0.xsd DEBUG - Trying to resolve XML entity with public id [null] and system id [http://www.springframework.org/schema/tx/spring-tx-2.0.xsd] DEBUG - Found XML schema [http://www.springframework.org/schema/tx/spring-tx-2.0.xsd] in classpath: org/springframework/transaction/config/spring-tx-2.0.xsd DEBUG - Trying to resolve XML entity with public id [null] and system id [http://www.springframework.org/schema/aop/spring-aop-2.0.xsd] DEBUG - Found XML schema [http://www.springframework.org/schema/aop/spring-aop-2.0.xsd] in classpath: org/springframework/aop/config/spring-aop-2.0.xsd DEBUG - Loaded mappings [{http://www.springframework.org/schema/p=org.springframework.beans.factory.xml.SimplePropertyNamespaceHandler, http://www.springframework.org/schema/lang=org.springframework.scripting.config.LangNamespaceHandler, http://www.springframework.org/schema/jee=org.springframework.ejb.config.JeeNamespaceHandler, http://www.springframework.org/schema/aop=org.springframework.aop.config.AopNamespaceHandler, http://www.springframework.org/schema/util=org.springframework.beans.factory.xml.UtilNamespaceHandler, http://www.springframework.org/schema/tx=org.springframework.transaction.config.TxNamespaceHandler}] DEBUG - Loading bean definitions DEBUG - Creating [java.util.LinkedHashMap] DEBUG - Loaded 8 bean definitions from location pattern [src/applicationContext.xml] INFO - Bean factory for application context [org.springframework.context.support.FileSystemXmlApplicationContext@8f4fb3]: org.springframework.beans.factory.support.DefaultListableBeanFactory@16c9867 DEBUG - 8 beans defined in org.springframework.context.support.FileSystemXmlApplicationContext@8f4fb3: display name [org.springframework.context.support.FileSystemXmlApplicationContext@8f4fb3]; startup date [Wed Jul 02 09:09:49 CST 2008]; root of context hierarchy DEBUG - Creating shared instance of singleton bean 'org.springframework.aop.config.internalAutoProxyCreator' DEBUG - Creating instance of bean 'org.springframework.aop.config.internalAutoProxyCreator' with merged definition [Root bean: class [org.springframework.aop.aspectj.autoproxy.AspectJAwareAdvisorAutoProxyCreator]; scope=singleton; abstract=false; lazyInit=false; autowireCandidate=true; autowireMode=0; dependencyCheck=0; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null] DEBUG - Getting BeanInfo for class [org.springframework.aop.aspectj.autoproxy.AspectJAwareAdvisorAutoProxyCreator] DEBUG - Caching PropertyDescriptors for class [org.springframework.aop.aspectj.autoproxy.AspectJAwareAdvisorAutoProxyCreator] DEBUG - Found bean property 'advisorAdapterRegistry' of type [org.springframework.aop.framework.adapter.AdvisorAdapterRegistry] DEBUG - Found bean property 'applyCommonInterceptorsFirst' of type [boolean] DEBUG - Found bean property 'beanClassLoader' of type [java.lang.ClassLoader] DEBUG - Found bean property 'beanFactory' of type [org.springframework.beans.factory.BeanFactory] DEBUG - Found bean property 'class' of type [java.lang.Class] DEBUG - Found bean property 'customTargetSourceCreators' of type [[Lorg.springframework.aop.framework.autoproxy.TargetSourceCreator;] DEBUG - Found bean property 'exposeProxy' of type [boolean] DEBUG - Found bean property 'frozen' of type [boolean] DEBUG - Found bean property 'interceptorNames' of type [[Ljava.lang.String;] DEBUG - Found bean property 'opaque' of type [boolean] DEBUG - Found bean property 'optimize' of type [boolean] DEBUG - Found bean property 'order' of type [int] DEBUG - Found bean property 'proxyTargetClass' of type [boolean] DEBUG - Creating [java.util.LinkedHashMap] DEBUG - Eagerly caching bean 'org.springframework.aop.config.internalAutoProxyCreator' to allow for resolving potential circular references INFO - Bean 'org.springframework.aop.config.internalAutoProxyCreator' is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) DEBUG - Unable to locate MessageSource with name 'messageSource': using default [org.springframework.context.support.DelegatingMessageSource@148662] DEBUG - Creating [java.util.LinkedHashSet] DEBUG - Unable to locate ApplicationEventMulticaster with name 'applicationEventMulticaster': using default [org.springframework.context.event.SimpleApplicationEventMulticaster@178460d] DEBUG - Creating [java.util.LinkedHashMap] INFO - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@16c9867: defining beans [myDataSource,SessionFactory,txManager,myadvice,org.springframework.aop.config.internalAutoProxyCreator,org.springframework.aop.aspectj.AspectJExpressionPointcut,org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor,CgnxDAO]; root of factory hierarchy DEBUG - Creating shared instance of singleton bean 'myDataSource' DEBUG - Creating instance of bean 'myDataSource' with merged definition [Root bean: class [org.springframework.jdbc.datasource.DriverManagerDataSource]; scope=singleton; abstract=false; lazyInit=false; autowireCandidate=true; autowireMode=0; dependencyCheck=0; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in file [F:\自助设备客户服务管理系统\工程\src\applicationContext.xml]] DEBUG - Getting BeanInfo for class [org.springframework.jdbc.datasource.DriverManagerDataSource] DEBUG - Caching PropertyDescriptors for class [org.springframework.jdbc.datasource.DriverManagerDataSource] DEBUG - Found bean property 'class' of type [java.lang.Class] DEBUG - Found bean property 'connection' of type [java.sql.Connection] DEBUG - Found bean property 'connectionProperties' of type [java.util.Properties] DEBUG - Found bean property 'driverClassName' of type [java.lang.String] DEBUG - Found bean property 'logWriter' of type [java.io.PrintWriter] DEBUG - Found bean property 'loginTimeout' of type [int] DEBUG - Found bean property 'password' of type [java.lang.String] DEBUG - Found bean property 'url' of type [java.lang.String] DEBUG - Found bean property 'username' of type [java.lang.String] DEBUG - Creating [java.util.LinkedHashMap] DEBUG - Eagerly caching bean 'myDataSource' to allow for resolving potential circular references INFO - Loaded JDBC driver: net.sourceforge.jtds.jdbc.Driver DEBUG - Creating shared instance of singleton bean 'org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor' DEBUG - Creating instance of bean 'org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor' with merged definition [Root bean: class [org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor]; scope=singleton; abstract=false; lazyInit=false; autowireCandidate=true; autowireMode=0; dependencyCheck=0; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null] DEBUG - Did not attempt to auto-proxy infrastructure class [org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor] DEBUG - Getting BeanInfo for class [org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor] DEBUG - Caching PropertyDescriptors for class [org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor] DEBUG - Found bean property 'advice' of type [org.aopalliance.aop.Advice] DEBUG - Found bean property 'adviceBeanName' of type [java.lang.String] DEBUG - Found bean property 'beanFactory' of type [org.springframework.beans.factory.BeanFactory] DEBUG - Found bean property 'class' of type [java.lang.Class] DEBUG - Found bean property 'order' of type [int] DEBUG - Found bean property 'perInstance' of type [boolean] DEBUG - Found bean property 'pointcut' of type [org.springframework.aop.Pointcut] DEBUG - Creating [java.util.LinkedHashMap] DEBUG - Eagerly caching bean 'org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor' to allow for resolving potential circular references DEBUG - Creating instance of bean 'org.springframework.aop.aspectj.AspectJExpressionPointcut' with merged definition [Root bean: class [org.springframework.aop.aspectj.AspectJExpressionPointcut]; scope=prototype; abstract=false; lazyInit=false; autowireCandidate=true; autowireMode=0; dependencyCheck=0; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null] DEBUG - Getting BeanInfo for class [org.springframework.aop.aspectj.AspectJExpressionPointcut] DEBUG - Caching PropertyDescriptors for class [org.springframework.aop.aspectj.AspectJExpressionPointcut] DEBUG - Found bean property 'class' of type [java.lang.Class] DEBUG - Found bean property 'classFilter' of type [org.springframework.aop.ClassFilter] DEBUG - Found bean property 'expression' of type [java.lang.String] DEBUG - Found bean property 'location' of type [java.lang.String] DEBUG - Found bean property 'methodMatcher' of type [org.springframework.aop.MethodMatcher] DEBUG - Found bean property 'parameterNames' of type [[Ljava.lang.String;] DEBUG - Found bean property 'parameterTypes' of type [[Ljava.lang.Class;] DEBUG - Found bean property 'pointcutDeclarationScope' of type [java.lang.Class] DEBUG - Found bean property 'pointcutExpression' of type [org.aspectj.weaver.tools.PointcutExpression] DEBUG - Found bean property 'runtime' of type [boolean] DEBUG - Creating [java.util.LinkedHashMap] DEBUG - Creating [java.util.LinkedHashSet] DEBUG - Creating shared instance of singleton bean 'SessionFactory' DEBUG - Creating instance of bean 'SessionFactory' with merged definition [Root bean: class [org.springframework.orm.hibernate3.LocalSessionFactoryBean]; scope=singleton; abstract=false; lazyInit=false; autowireCandidate=true; autowireMode=0; dependencyCheck=0; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in file [F:\自助设备客户服务管理系统\工程\src\applicationContext.xml]] DEBUG - Getting BeanInfo for class [org.springframework.orm.hibernate3.LocalSessionFactoryBean] DEBUG - Caching PropertyDescriptors for class [org.springframework.orm.hibernate3.LocalSessionFactoryBean] DEBUG - Found bean property 'cacheableMappingLocations' of type [[Lorg.springframework.core.io.Resource;] DEBUG - Found bean property 'class' of type [java.lang.Class] DEBUG - Found bean property 'collectionCacheStrategies' of type [java.util.Properties] DEBUG - Found bean property 'configLocation' of type [org.springframework.core.io.Resource] DEBUG - Found bean property 'configLocations' of type [[Lorg.springframework.core.io.Resource;] DEBUG - Found bean property 'configuration' of type [org.hibernate.cfg.Configuration] DEBUG - Found bean property 'configurationClass' of type [java.lang.Class] DEBUG - Found bean property 'dataSource' of type [javax.sql.DataSource] DEBUG - Found bean property 'entityCacheStrategies' of type [java.util.Properties] DEBUG - Found bean property 'entityInterceptor' of type [org.hibernate.Interceptor] DEBUG - Found bean property 'eventListeners' of type [java.util.Map] DEBUG - Found bean property 'exposeTransactionAwareSessionFactory' of type [boolean] DEBUG - Found bean property 'filterDefinitions' of type [[Lorg.hibernate.engine.FilterDefinition;] DEBUG - Found bean property 'hibernateProperties' of type [java.util.Properties] DEBUG - Found bean property 'jdbcExceptionTranslator' of type [org.springframework.jdbc.support.SQLExceptionTranslator] DEBUG - Found bean property 'jtaTransactionManager' of type [javax.transaction.TransactionManager] DEBUG - Found bean property 'lobHandler' of type [org.springframework.jdbc.support.lob.LobHandler] DEBUG - Found bean property 'mappingDirectoryLocations' of type [[Lorg.springframework.core.io.Resource;] DEBUG - Found bean property 'mappingJarLocations' of type [[Lorg.springframework.core.io.Resource;] DEBUG - Found bean property 'mappingLocations' of type [[Lorg.springframework.core.io.Resource;] DEBUG - Found bean property 'mappingResources' of type [[Ljava.lang.String;] DEBUG - Found bean property 'namingStrategy' of type [org.hibernate.cfg.NamingStrategy] DEBUG - Found bean property 'object' of type [java.lang.Object] DEBUG - Found bean property 'objectType' of type [java.lang.Class] DEBUG - Found bean property 'schemaUpdate' of type [boolean] DEBUG - Found bean property 'singleton' of type [boolean] DEBUG - Found bean property 'typeDefinitions' of type [[Lorg.springframework.orm.hibernate3.TypeDefinitionBean;] DEBUG - Found bean property 'useTransactionAwareDataSource' of type [boolean] DEBUG - Creating [java.util.LinkedHashMap] DEBUG - Eagerly caching bean 'SessionFactory' to allow for resolving potential circular references DEBUG - Returning cached instance of singleton bean 'myDataSource' DEBUG - Creating [java.util.LinkedHashSet] DEBUG - Creating [java.util.LinkedHashMap] INFO - Hibernate 3.1.3 INFO - hibernate.properties not found INFO - using CGLIB reflection optimizer INFO - using JDK 1.4 java.sql.Timestamp handling DEBUG - trying to resolve system-id [http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd] DEBUG - recognized hibernate namespace; attempting to resolve on classpath under org/hibernate/ DEBUG - located [http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd] in classpath INFO - Mapping class: com.yhwj.secsms.po.Cgnx -> cgnx DEBUG - Mapped property: cgnxId -> cgnxID DEBUG - Mapped property: cgnx -> cgnx INFO - Building new Hibernate SessionFactory DEBUG - Preparing to build session factory with filters : {} DEBUG - processing extends queue DEBUG - processing collection mappings DEBUG - processing native query and ResultSetMapping mappings DEBUG - processing association property references DEBUG - processing foreign key constraints INFO - Initializing connection provider: org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider DEBUG - Creating new JDBC Connection to [jdbc:jtds:sqlserver://localhost:1433/soft2005] INFO - RDBMS: Microsoft SQL Server, version: 08.00.2039 INFO - JDBC driver: jTDS Type 4 JDBC Driver for MS SQL Server and Sybase, version: 1.2.2 INFO - Using dialect: org.hibernate.dialect.SybaseDialect INFO - Using default transaction strategy (direct JDBC transactions) INFO - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended) INFO - Automatic flush during beforeCompletion(): disabled INFO - Automatic session close at end of transaction: disabled INFO - Scrollable result sets: enabled DEBUG - Wrap result sets: disabled INFO - JDBC3 getGeneratedKeys(): enabled INFO - Connection release mode: on_close INFO - Default batch fetch size: 1 INFO - Generate SQL with comments: disabled INFO - Order SQL updates by primary key: disabled INFO - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory INFO - Using ASTQueryTranslatorFactory INFO - Query language substitutions: {} INFO - Second-level cache: enabled INFO - Query cache: disabled INFO - Cache provider: org.hibernate.cache.EhCacheProvider INFO - Optimize cache for minimal puts: disabled INFO - Structured second-level cache entries: disabled DEBUG - Using dialect defined converter INFO - Statistics: disabled INFO - Deleted entity synthetic identifier rollback: disabled INFO - Default entity-mode: pojo INFO - building session factory DEBUG - Session factory constructed with filter configurations : {} DEBUG - instantiating session factory with properties: {java.runtime.name=Java(TM) 2 Runtime Environment, Standard Edition, sun.boot.library.path=D:\Program Files\MyEclipse 5.5 GA\jre\bin, java.vm.version=1.5.0_11-b03, java.vm.vendor=Sun Microsystems Inc., java.vendor.url=http://java.sun.com/, path.separator=;, java.vm.name=Java HotSpot(TM) Client VM, file.encoding.pkg=sun.io, user.country=CN, sun.java.launcher=SUN_STANDARD, sun.os.patch.level=Service Pack 3, java.vm.specification.name=Java Virtual Machine Specification, user.dir=F:\自助设备客户服务管理系统\工程, java.runtime.version=1.5.0_11-b03, java.awt.graphicsenv=sun.awt.Win32GraphicsEnvironment, java.endorsed.dirs=D:\Program Files\MyEclipse 5.5 GA\jre\lib\endorsed, os.arch=x86, java.io.tmpdir=C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\, line.separator= , java.vm.specification.vendor=Sun Microsystems Inc., user.variant=, os.name=Windows XP, sun.jnu.encoding=GBK, java.library.path=D:\Program Files\MyEclipse 5.5 GA\jre\bin;.;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\Java\jdk1.5.0_07\\bin;C:\Program Files\Microsoft SQL Server\80\Tools\BINN;C:\Program Files\StormII\Codec;C:\Program Files\StormII, java.specification.name=Java Platform API Specification, java.class.version=49.0, sun.management.compiler=HotSpot Client Compiler, os.version=5.1, user.home=C:\Documents and Settings\Administrator, user.timezone=Asia/Shanghai, hibernate.connection.release_mode=on_close, java.awt.printerjob=sun.awt.windows.WPrinterJob, file.encoding=GBK, java.specification.version=1.5, java.class.path=F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\classes;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\jstl.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\standard.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\antlr-2.7.6rc1.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\asm-attrs.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\asm.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\c3p0-0.9.0.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\cglib-2.1.3.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\commons-collections-2.1.1.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\commons-logging-1.0.4.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\concurrent-1.3.2.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\connector.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\dom4j-1.6.1.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\ehcache-1.1.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\hibernate3.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\jaas.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\jacc-1_0-fr.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\jaxen-1.1-beta-7.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\jboss-cache.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\jboss-common.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\jboss-jmx.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\jboss-system.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\jdbc2_0-stdext.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\jgroups-2.2.8.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\jta.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\jtds-1.2.2.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\log4j-1.2.11.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\oscache-2.1.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\proxool-0.8.3.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\swarmcache-1.0rc2.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\xerces-2.6.2.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\xml-apis.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\aopalliance.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\asm-2.2.3.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\asm-commons-2.2.3.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\asm-util-2.2.3.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\aspectjrt.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\aspectjweaver.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\backport-util-concurrent.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\bsh-2.0b4.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\c3p0-0.9.1.1.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\cglib-nodep-2.1_3.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\commonj-twm.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\commons-attributes-api.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\commons-attributes-compiler.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\commons-dbcp.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\commons-lang.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\commons-logging.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\ehcache-1.2.4.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\groovy-1.0.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\hessian-3.0.20.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\hibernate-annotations.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\hibernate-commons-annotations.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\hibernate-entitymanager.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\ibatis-2.3.0.677.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\jakarta-oro-2.0.8.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\jamon-2.4.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\jboss-archive-browsing.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\jdo2-api.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\jmxremote.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\jmxremote_optional.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\jmxri.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\jotm.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\jruby.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\log4j-1.2.14.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\openjpa-0.9.7-incubating.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\persistence.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\quartz-all-1.6.0.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\serp-1.12.1.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\spring-agent.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\spring-aop.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\spring-beans.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\spring-context.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\spring-core.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\spring-dao.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\spring-hibernate3.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\spring-ibatis.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\spring-jdbc.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\spring-jdo.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\spring-jmx.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\spring-jpa.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\spring-remoting.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\spring-support.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\spring-tomcat-weaver.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\spring-toplink.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\toplink-api.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\toplink-essentials.jar;F:\自助设备客户服务管理系统\工程\WebRoot\WEB-INF\lib\xapool.jar;D:\Program Files\MyEclipse 5.5 GA\eclipse\plugins\org.junit_3.8.1\junit.jar;/D:/Program Files/MyEclipse 5.5 GA/eclipse/plugins/org.eclipse.jdt.junit_3.2.1.r321_v20060810/junitsupport.jar;/D:/Program Files/MyEclipse 5.5 GA/eclipse/plugins/org.eclipse.jdt.junit.runtime_3.2.1.r321_v20060721/junitruntime.jar, user.name=Administrator, java.vm.specification.version=1.0, sun.arch.data.model=32, java.home=D:\Program Files\MyEclipse 5.5 GA\jre, hibernate.dialect=org.hibernate.dialect.SybaseDialect, java.specification.vendor=Sun Microsystems Inc., user.language=zh, awt.toolkit=sun.awt.windows.WToolkit, java.vm.info=mixed mode, hibernate.cglib.use_reflection_optimizer=true, java.version=1.5.0_11, java.ext.dirs=D:\Program Files\MyEclipse 5.5 GA\jre\lib\ext, sun.boot.class.path=D:\Program Files\MyEclipse 5.5 GA\jre\lib\rt.jar;D:\Program Files\MyEclipse 5.5 GA\jre\lib\i18n.jar;D:\Program Files\MyEclipse 5.5 GA\jre\lib\sunrsasign.jar;D:\Program Files\MyEclipse 5.5 GA\jre\lib\jsse.jar;D:\Program Files\MyEclipse 5.5 GA\jre\lib\jce.jar;D:\Program Files\MyEclipse 5.5 GA\jre\lib\charsets.jar;D:\Program Files\MyEclipse 5.5 GA\jre\classes;D:\Program Files\MyEclipse 5.5 GA\myeclipse\eclipse\plugins\com.genuitec.eclipse.j2eedt.core_5.5.0\data\libraryset\1.4\activation.jar;D:\Program Files\MyEclipse 5.5 GA\myeclipse\eclipse\plugins\com.genuitec.eclipse.j2eedt.core_5.5.0\data\libraryset\1.4\javax.servlet.jar;D:\Program Files\MyEclipse 5.5 GA\myeclipse\eclipse\plugins\com.genuitec.eclipse.j2eedt.core_5.5.0\data\libraryset\1.4\javax.servlet.jsp.jar;D:\Program Files\MyEclipse 5.5 GA\myeclipse\eclipse\plugins\com.genuitec.eclipse.j2eedt.core_5.5.0\data\libraryset\1.4\jboss-j2ee.jar;D:\Program Files\MyEclipse 5.5 GA\myeclipse\eclipse\plugins\com.genuitec.eclipse.j2eedt.core_5.5.0\data\libraryset\1.4\jboss-jaxrpc.jar;D:\Program Files\MyEclipse 5.5 GA\myeclipse\eclipse\plugins\com.genuitec.eclipse.j2eedt.core_5.5.0\data\libraryset\1.4\jboss-jsr77.jar;D:\Program Files\MyEclipse 5.5 GA\myeclipse\eclipse\plugins\com.genuitec.eclipse.j2eedt.core_5.5.0\data\libraryset\1.4\jboss-saaj.jar;D:\Program Files\MyEclipse 5.5 GA\myeclipse\eclipse\plugins\com.genuitec.eclipse.j2eedt.core_5.5.0\data\libraryset\1.4\mail.jar;D:\Program Files\MyEclipse 5.5 GA\myeclipse\eclipse\plugins\com.genuitec.eclipse.j2eedt.core_5.5.0\data\libraryset\1.4\namespace.jar;D:\Program Files\MyEclipse 5.5 GA\myeclipse\eclipse\plugins\com.genuitec.eclipse.j2eedt.core_5.5.0\data\libraryset\1.4\xml-apis.jar, java.vendor=Sun Microsystems Inc., file.separator=\, java.vendor.url.bug=http://java.sun.com/cgi-bin/bugreport.cgi, hibernate.connection.provider_class=org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider, sun.cpu.endian=little, sun.io.unicode.encoding=UnicodeLittle, sun.desktop=windows, sun.cpu.isalist=pentium_pro+mmx pentium_pro pentium+mmx pentium i486 i386 i86} DEBUG - Creating new CacheManager with default config DEBUG - Configuring ehcache from classpath. WARN - No configuration found. Configuring ehcache from ehcache-failsafe.xml found in the classpath: jar:file:/F:/%e8%87%aa%e5%8a%a9%e8%ae%be%e5%a4%87%e5%ae%a2%e6%88%b7%e6%9c%8d%e5%8a%a1%e7%ae%a1%e7%90%86%e7%b3%bb%e7%bb%9f/%e5%b7%a5%e7%a8%8b/WebRoot/WEB-INF/lib/ehcache-1.1.jar!/ehcache-failsafe.xml DEBUG - Disk Store Path: C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\ DEBUG - Static SQL for entity: com.yhwj.secsms.po.Cgnx DEBUG - Version select: select cgnxID from secsms.dbo.cgnx where cgnxID =? DEBUG - Snapshot select: select cgnx_.cgnxID, cgnx_.cgnx as cgnx0_ from secsms.dbo.cgnx cgnx_ where cgnx_.cgnxID=? DEBUG - Insert 0: insert into secsms.dbo.cgnx (cgnx, cgnxID) values (?, ?) DEBUG - Update 0: update secsms.dbo.cgnx set cgnx=? where cgnxID=? DEBUG - Delete 0: delete from secsms.dbo.cgnx where cgnxID=? DEBUG - Identity insert: insert into secsms.dbo.cgnx (cgnx) values (?) DEBUG - Static select for entity com.yhwj.secsms.po.Cgnx: select cgnx0_.cgnxID as cgnxID0_0_, cgnx0_.cgnx as cgnx0_0_ from secsms.dbo.cgnx cgnx0_ where cgnx0_.cgnxID=? DEBUG - Static select for entity com.yhwj.secsms.po.Cgnx: select cgnx0_.cgnxID as cgnxID0_0_, cgnx0_.cgnx as cgnx0_0_ from secsms.dbo.cgnx cgnx0_ where cgnx0_.cgnxID=? DEBUG - Static select for entity com.yhwj.secsms.po.Cgnx: select cgnx0_.cgnxID as cgnxID0_0_, cgnx0_.cgnx as cgnx0_0_ from secsms.dbo.cgnx cgnx0_ where cgnx0_.cgnxID=? DEBUG - Static select for entity com.yhwj.secsms.po.Cgnx: select cgnx0_.cgnxID as cgnxID0_0_, cgnx0_.cgnx as cgnx0_0_ from secsms.dbo.cgnx cgnx0_ where cgnx0_.cgnxID=? DEBUG - Static select for action ACTION_MERGE on entity com.yhwj.secsms.po.Cgnx: select cgnx0_.cgnxID as cgnxID0_0_, cgnx0_.cgnx as cgnx0_0_ from secsms.dbo.cgnx cgnx0_ where cgnx0_.cgnxID=? DEBUG - Static select for action ACTION_REFRESH on entity com.yhwj.secsms.po.Cgnx: select cgnx0_.cgnxID as cgnxID0_0_, cgnx0_.cgnx as cgnx0_0_ from secsms.dbo.cgnx cgnx0_ where cgnx0_.cgnxID=? DEBUG - initializing class SessionFactoryObjectFactory DEBUG - registered: 4028808b1ae151ae011ae151b9410000 (unnamed) INFO - Not binding factory to JNDI, no JNDI name configured DEBUG - instantiated session factory DEBUG - Checking 0 named HQL queries DEBUG - Checking 0 named SQL queries DEBUG - Returning cached instance of singleton bean 'org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor' DEBUG - Creating shared instance of singleton bean 'txManager' DEBUG - Creating instance of bean 'txManager' with merged definition [Root bean: class [org.springframework.orm.hibernate3.HibernateTransactionManager]; scope=singleton; abstract=false; lazyInit=false; autowireCandidate=true; autowireMode=0; dependencyCheck=0; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in file [F:\自助设备客户服务管理系统\工程\src\applicationContext.xml]] DEBUG - Getting BeanInfo for class [org.springframework.orm.hibernate3.HibernateTransactionManager] DEBUG - Caching PropertyDescriptors for class [org.springframework.orm.hibernate3.HibernateTransactionManager] DEBUG - Found bean property 'autodetectDataSource' of type [boolean] DEBUG - Found bean property 'beanFactory' of type [org.springframework.beans.factory.BeanFactory] DEBUG - Found bean property 'class' of type [java.lang.Class] DEBUG - Found bean property 'dataSource' of type [javax.sql.DataSource] DEBUG - Found bean property 'defaultTimeout' of type [int] DEBUG - Found bean property 'entityInterceptor' of type [org.hibernate.Interceptor] DEBUG - Found bean property 'entityInterceptorBeanName' of type [java.lang.String] DEBUG - Found bean property 'failEarlyOnGlobalRollbackOnly' of type [boolean] DEBUG - Found bean property 'globalRollbackOnParticipationFailure' of type [boolean] DEBUG - Found bean property 'jdbcExceptionTranslator' of type [org.springframework.jdbc.support.SQLExceptionTranslator] DEBUG - Found bean property 'nestedTransactionAllowed' of type [boolean] DEBUG - Found bean property 'prepareConnection' of type [boolean] DEBUG - Found bean property 'resourceFactory' of type [java.lang.Object] DEBUG - Found bean property 'rollbackOnCommitFailure' of type [boolean] DEBUG - Found bean property 'sessionFactory' of type [org.hibernate.SessionFactory] DEBUG - Found bean property 'transactionSynchronization' of type [int] DEBUG - Found bean property 'transactionSynchronizationName' of type [java.lang.String] DEBUG - Creating [java.util.LinkedHashMap] DEBUG - Eagerly caching bean 'txManager' to allow for resolving potential circular references DEBUG - Returning cached instance of singleton bean 'SessionFactory' DEBUG - Returning cached instance of singleton bean 'org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor' DEBUG - Creating [java.util.LinkedHashSet] INFO - Using DataSource [org.springframework.jdbc.datasource.DriverManagerDataSource@76db09] of Hibernate SessionFactory for HibernateTransactionManager DEBUG - Returning cached instance of singleton bean 'org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor' DEBUG - Creating shared instance of singleton bean 'myadvice' DEBUG - Creating instance of bean 'myadvice' with merged definition [Root bean: class [org.springframework.transaction.interceptor.TransactionInterceptor]; scope=singleton; abstract=false; lazyInit=false; autowireCandidate=true; autowireMode=0; dependencyCheck=0; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null] DEBUG - Did not attempt to auto-proxy infrastructure class [org.springframework.transaction.interceptor.TransactionInterceptor] DEBUG - Getting BeanInfo for class [org.springframework.transaction.interceptor.TransactionInterceptor] DEBUG - Caching PropertyDescriptors for class [org.springframework.transaction.interceptor.TransactionInterceptor] DEBUG - Found bean property 'class' of type [java.lang.Class] DEBUG - Found bean property 'transactionAttributeSource' of type [org.springframework.transaction.interceptor.TransactionAttributeSource] DEBUG - Found bean property 'transactionAttributeSources' of type [[Lorg.springframework.transaction.interceptor.TransactionAttributeSource;] DEBUG - Found bean property 'transactionAttributes' of type [java.util.Properties] DEBUG - Found bean property 'transactionManager' of type [org.springframework.transaction.PlatformTransactionManager] DEBUG - Creating [java.util.LinkedHashMap] DEBUG - Eagerly caching bean 'myadvice' to allow for resolving potential circular references DEBUG - Returning cached instance of singleton bean 'txManager' DEBUG - Creating [java.util.LinkedHashSet] DEBUG - Creating instance of bean '(inner bean)' with merged definition [Root bean: class [org.springframework.transaction.interceptor.NameMatchTransactionAttributeSource]; scope=singleton; abstract=false; lazyInit=false; autowireCandidate=true; autowireMode=0; dependencyCheck=0; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null] DEBUG - Getting BeanInfo for class [org.springframework.transaction.interceptor.NameMatchTransactionAttributeSource] DEBUG - Caching PropertyDescriptors for class [org.springframework.transaction.interceptor.NameMatchTransactionAttributeSource] DEBUG - Found bean property 'class' of type [java.lang.Class] DEBUG - Found bean property 'nameMap' of type [java.util.Map] DEBUG - Found bean property 'properties' of type [java.util.Properties] DEBUG - Creating [java.util.LinkedHashMap] DEBUG - Creating [java.util.LinkedHashMap] DEBUG - Adding transactional method [*] with attribute [PROPAGATION_REQUIRED,ISOLATION_DEFAULT] DEBUG - Returning cached instance of singleton bean 'org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor' DEBUG - Creating [java.util.LinkedHashSet] DEBUG - Creating shared instance of singleton bean 'CgnxDAO' DEBUG - Creating instance of bean 'CgnxDAO' with merged definition [Root bean: class [com.yhwj.secsms.dao.CgnxDAO]; scope=singleton; abstract=false; lazyInit=false; autowireCandidate=true; autowireMode=0; dependencyCheck=0; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in file [F:\自助设备客户服务管理系统\工程\src\applicationContext.xml]] DEBUG - Getting BeanInfo for class [com.yhwj.secsms.dao.CgnxDAO] DEBUG - Caching PropertyDescriptors for class [com.yhwj.secsms.dao.CgnxDAO] DEBUG - Found bean property 'class' of type [java.lang.Class] DEBUG - Found bean property 'hibernateTemplate' of type [org.springframework.orm.hibernate3.HibernateTemplate] DEBUG - Found bean property 'sessionFactory' of type [org.hibernate.SessionFactory] DEBUG - Creating [java.util.LinkedHashMap] DEBUG - Eagerly caching bean 'CgnxDAO' to allow for resolving potential circular references DEBUG - Returning cached instance of singleton bean 'SessionFactory' DEBUG - Returning cached instance of singleton bean 'org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor' DEBUG - Returning cached instance of singleton bean 'myadvice' DEBUG - Creating [java.util.IdentityHashMap] DEBUG - Creating implicit proxy for bean 'CgnxDAO' with 0 common interceptors and 1 specific interceptors DEBUG - Creating JDK dynamic proxy: target source is SingletonTargetSource for target object [com.yhwj.secsms.dao.CgnxDAO@19855ed] DEBUG - Publishing event in context [org.springframework.context.support.FileSystemXmlApplicationContext@8f4fb3]: org.springframework.context.event.ContextRefreshedEvent[source=org.springframework.context.support.FileSystemXmlApplicationContext@8f4fb3: display name [org.springframework.context.support.FileSystemXmlApplicationContext@8f4fb3]; startup date [Wed Jul 02 09:09:49 CST 2008]; root of context hierarchy] DEBUG - Returning cached instance of singleton bean 'CgnxDAO'

在Main方法中获取spring Bean,调用Bean方法后,程序不能终止?

Main方法如下: [code="java"] public static void main(String[] args) { ApplicationContext context = new ClassPathXmlApplicationContext( new String[] {"ApplicationContext-jotm.xml"}); BeanFactory factory = (BeanFactory) context; UserService userService = (UserService)factory.getBean("userService"); if(args[0].equals("help") || args[0].equals("?")){ System.out.println("-------------------------"); System.out.println("equip 设备同步"); System.out.println("-------------------------"); } if(args[0].equals("equip")){ userService.synchronyEquipment(); } } [/code] 测试里面调用userService.synchronyEquipment(),可以正常终止。Main方法操作执行了,但程序不能终止。 我使用jotm操作两个数据库。我想是不是spring没有释放数据库连接? 不知道有人遇到过这种情况没有? ApplicationContext-jotm.xml [code="xml"] <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"> <bean id="jotm" class="org.springframework.transaction.jta.JotmFactoryBean"/> <bean id="txManager" class="org.springframework.transaction.jta.JtaTransactionManager"> <property name="userTransaction" ref="jotm" /> </bean> <bean id="eamds" class="org.enhydra.jdbc.pool.StandardXAPoolDataSource" destroy-method="shutdown"> <property name="dataSource"> <bean class="org.enhydra.jdbc.standard.StandardXADataSource" destroy-method="shutdown"> <property name="transactionManager" ref="jotm" /> <property name="driverName" value="com.mysql.jdbc.Driver" /> <property name="url" value="jdbc:mysql://localhost/d7i" /> </bean> </property> <property name="user" value="root" /> <property name="password" value="root"/> </bean> <bean id="zhjds" class="org.enhydra.jdbc.pool.StandardXAPoolDataSource" destroy-method="shutdown"> <property name="dataSource"> <bean class="org.enhydra.jdbc.standard.StandardXADataSource" destroy-method="shutdown"> <property name="transactionManager" ref="jotm" /> <!-- property name="driverName" value="oracle.jdbc.driver.OracleDriver" /> <property name="url" value="jdbc:oracle:thin:@10.10.150.216:1521:eampoc" /--> <property name="driverName" value="com.mysql.jdbc.Driver" /> <property name="url" value="jdbc:mysql://localhost/eampoc"/> </bean> </property> <property name="user" value="root" /> <property name="password" value="root" /> </bean> <bean id="template1" class="org.springframework.jdbc.core.JdbcTemplate"> <property name="dataSource" ref="eamds" /> </bean> <bean id="template2" class="org.springframework.jdbc.core.JdbcTemplate"> <property name="dataSource" ref="zhjds" /> </bean> <bean id="EAMDao" class="com.hgsoft.EAMDAO"> <property name="jdbcTemplate"> <ref bean="template1"></ref> </property> <property name="fetchSize" value="1"/> </bean> <bean id="ZHJDao" class="com.hgsoft.ZHJDAO"> <property name="jdbcTemplate"> <ref bean="template2"></ref> </property> </bean> <bean id="userService" class="com.hgsoft.UserServiceImpl"> <property name="EAMDao" ref="EAMDao"/> <property name="executeService" ref="executeService"/> <property name="yaml" ref="yaml"/> <property name="yamlStr"> <value>equipment: count: select count(*) from new_object_collection t where t.issended='0' query: select t.equip_code,t.equip_name,t.sealflag from new_object_collection t where t.issended='0' update: update new_object_collection set issended='1' where equip_code=? insert: insert into eam_ncinv_equip (EQUIP_CODE,EQUIP_NAME,SEALFLAG ) values (?,?,?)</value> </property> </bean> <bean id="yaml" class="org.yaml.snakeyaml.Yaml" scope="prototype" /> <bean id="executeServiceTarget" class="com.hgsoft.ExecuteService"> <property name="EAMDao" ref="EAMDao"/> <property name="ZHJDao" ref="ZHJDao"/> </bean> <bean id="executeService" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"> <property name="transactionManager"> <ref bean="txManager"/> </property> <property name="target"> <ref bean="executeServiceTarget"/> </property> <property name="transactionAttributes"> <props> <prop key="executeSynchrony">PROPAGATION_REQUIRES_NEW,-Exception</prop> </props> </property> </bean> </beans> [/code]

spring配置set注入时,properties中的name只能使用先前配置过的bean的id。

``` <bean id="EmployeeAction" scope="prototype" class="com.tw.web.action.EmployeeAction"> <property name="employeeDao" ref="employeeDao"/> <property name="baseDao" ref="employeeDao"/> <property name="dao" ref="employeeDao"/> </bean> ``` 以上三种情况: 第一种(employeeDao):可以正确注入 第二种(baseDao):由于配置中有一个id="baseDao"的抽象bean,所以会报错:baseDao这bean是一个抽象bean。 第三种(dao):根本不进入set中。 先前我一直纳闷为什么name和ref的字符串不一样就不能够正确注入。直到看到第二种配置报的错,才发现name直接就对应了配置中bean的id了。 是这样的: 我的配置中确实存在一个id="baseDao"的抽象类 但是在注入时,baseDao只是一个属性。相当于: public void setBaseDao(IEmployeeDao employeeDao){} 我的配置是: ``` <property name="baseDao", ref="employeeDao" /> ``` 那么Spring按理应该是通过ref去找id="employeeDao"的bean然后注入到setBaseDao中。 但是我遇到的问题是,Spring是通过name去找id="baseDao"的bean。 另外, ``` <property name="id", value="1" /> ``` 这样的形式也不行。 奇怪的是,配置SessionFactory的时候并没有问题。 **刚刚在相关提问中找到一个解决方法:把Struts配置中的class="类全限定名",改成Spring配置的bean的id就行了。还是想请问一下有谁知道是什么问题吗?** 谢谢各位!

关于spring的singleton bean

Spring IoC容器中只会存在一个共享的bean实例,这个单一实例会被存储到单例缓存(singleton cache)中,并且所有针对该bean的后续请求和引用都将返回被缓存的对象实例。我想知道设计模式中的Singleton模式与spring中的singleton bean之间有什么区别? 还有个比较傻的问题:用户登录后获得一个session,很多用户对bean进行操作,而bean是单例的,那bean对象中的数据岂不是乱了? :oops: [b]问题补充:[/b] 一楼的朋友好像没有仔细看问题,答非所问啊。 我查资料说,“singleton bean的作用域可以描述为一个container对应一个bean实例” 在问答里也有朋友提出了跟我相似的疑问[url]http://www.iteye.com/problems/27340[/url] [b]问题补充:[/b] 补充一楼:spring相对于EJB来说“对所有有状态的bean应该使用prototype作用域,而对无状态的bean则应该使用singleton作用域。” 那就是说,在classloader中只有一个singleton bean,说的在准确点就是“singleton bean在初始化后只有一个单例存在于spring container中”? 但是资料上说“Spring的singleton bean概念与“四人帮”(GoF)模式一书中定义的Singleton模式是[b]完全不同[/b]的。经典的GoF Singleton模式中所谓的对象范围是指在每一个ClassLoader中指定class创建的实例有且仅有一个。把Spring的singleton作用域描述成一个container对应一个bean实例最为贴切。亦即,假如在单个Spring容器内定义了某个指定class的bean,那么Spring容器将会创建一个且仅有一个由该bean定义指定的类实例。” 它的意思好像是说,在一个ClassLoader中可能有多个container,而一个container中只能有一个singleton bean,我理解的对吗?哪位能再解释下? [b]问题补充:[/b] 感谢大家的回答,但是分只能给一个人,我觉得heaven的回答我很满意。

来个大神教我配置Spring的bean生命周期

bean配置默认是单例,使用autowired没问题 ``` <bean id="userDao" class="org.mybatis.spring.mapper.MapperFactoryBean"> <property name="mapperInterface" value="Dao.UserDao"></property> <property name="sqlSessionFactory" ref="sqlSessionFactory"></property> </bean> ``` 我想配置它每次请求这个bean就生成一个实例 然后就炸了 ``` <!--Dao配置--> <bean id="userDao" class="org.mybatis.spring.mapper.MapperFactoryBean" scope="prototype"> <property name="mapperInterface" value="Dao.UserDao"></property> <property name="sqlSessionFactory" ref="sqlSessionFactory"></property> </bean> <!--Service配置--> <bean id="userService" class="Service.UserService" scope="prototype"> <property name="uDao" ref="userDao"></property> </bean> ``` ``` import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import Common.InitDataBases; import Common.Controller.OutputStringController; import Dao.UserDao; import Model.User; import java.util.List; import org.apache.log4j.Logger; @Controller public class Hello extends OutputStringController{ @Autowired private UserDao uDao; //数据库测试 @RequestMapping(value = "/getUser", produces = "text/html;charset=UTF-8") @ResponseBody public String dbTest(String username) { System.out.println(uDao.findByUsername(username).getUsername()); return success(""); } } ``` ``` import java.util.List; import org.apache.ibatis.annotations.Param; import Model.User; public interface UserDao { //查询 public User findById(long id); public User findByUsernameAndPassword(@Param("username")String username,@Param("password")String password); public User findByUsername(String username); public List<User> findByDepartment(long department); //插入 public int applyUser(User u); } ``` ``` 2017-04-01 13:30:56 ERROR [http-bio-8080-exec-6] org.springframework.web.servlet.DispatcherServlet - Context initialization failed org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'hello': Unsatisfied dependency expressed through field 'uDao'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'Dao.UserDao' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:588) at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:366) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1225) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:552) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:759) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:866) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542) at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:668) at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:634) at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:682) at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:553) at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:494) at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136) at javax.servlet.GenericServlet.init(GenericServlet.java:158) at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1282) at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1195) at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:866) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:134) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:442) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1082) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:623) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:745) Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'Dao.UserDao' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1474) at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1102) at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1064) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:585) ... 37 more ```

spring创建多例对象的时候,默认对照xml中bean的id会是什么呢?

``` @Service @Scope("prototype") public class DemoService implements BeanNameAware{ private String beanName; public void outputResult() { System.out.println("获取bean:"+this+",beanName:"+beanName); } @Override public void setBeanName(String name) { this.beanName = name; } } ``` 获取demoService的示例 ``` public void newBean() { ThreadPoolExecutor executor = (ThreadPoolExecutor) Executors.newCachedThreadPool(); for (int i = 0; i < 5; i++) { executor.execute(new Runnable() { @Override public void run() { DemoService demo = context.getBean(DemoService.class); demo.outputResult(); } }); } } ``` 每一次获取到的beanName都是demoService,觉得获取到的不是bean的id而是bean的name,所以在并发获取多个实例的时候每个bean的id应该是什么?不是不应该重复吗?

spring中for循环创建bean疑问

Spring配置文件内容片断: <bean id="student" class="com.Student" scope="prototype"> <!-- bean --> <bean id="studentAction" class="com.StudentAction" scope="prototype"> <!-- action --> <property name="listStudent"> <list><ref local="student"/> </list> </property> </bean> Struts2中的action文件内容片断: private List<Student> listStudent; for(int i=0; i<list1.size(); i++){ Studnet student = new Student(); student.setName("name1"); listStudent.add(i,student); } 疑问:listStudent每次add时都是放入新的student实例,Studnet类已经被Spring管理了,肯定是不需要每次都new一个实例,求解决办法

spring容器中bean的作用域?

作用域的作用??求个通俗点的例子关于singleton和prototype区别

Spring的destroy方法不执行

Spring可以通过配置init-method和destroy-method属性来在容器生成和销毁时分别执行一段代码,但在我的demo中,作为init方法的start方法执行了,而作为destroy方法的shutdown方法一直没有执行,代码如下: 配置文件: ``` <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> <bean class="com.ljh.beans.Foo2" id="foo2" scope="prototype" init-method="start" destroy-method="shutdown"> <property name="foo" ref="foo"></property> </bean> <bean class="com.ljh.beans.Foo" id="foo" scope="prototype"> <property name="num" value="2"></property> </bean> </beans> ``` Bean文件: ``` public class Foo2 { private Foo foo; public void say(){ System.out.println("Foo2 method:" + foo.hashCode()); System.out.println("Foo2 hashcode" + this.hashCode()); System.out.println("----------------------"); } private void start() { System.out.println("Start method"); } private void shutdown() { System.out.println("Shutdown method"); } public Foo getFoo() { return foo; } public void setFoo(Foo foo) { this.foo = foo; } } ``` 测试方法: ``` public class Test01 { private ApplicationContext context; @Before public void init() { context = new ClassPathXmlApplicationContext("/springConfig.xml"); } @Test public void Test() { Foo2 foo2 = (Foo2) context.getBean("foo2"); System.out.println(foo2.getFoo().getNum()); } @After public void After() { System.out.println("In after method"); ((ClassPathXmlApplicationContext) context).close(); } ```

spring 中配置bean的注入是<property>的name与与ref的id名需要一样吗??

[code="java"] <bean id="iService" class="com.lopu.framework.service.IServiceImpl"> <property name="dao" ref="dao"></property> </bean> <bean id="fnBean" class="com.lopu.framework.modules.maintain.action.FlightNatureAction" scope="prototype"> <property name="fnService">//此name必须是iService吗??? <ref bean="iService" /> </property> </bean> [/code] [code="java"]public class FlightNatureAction extends ActionSupport implements ModelDriven<FlightNature> { private IService fnService; private List<FlightNature> fnLists = new ArrayList<FlightNature>(); private FlightNature fnBean = new FlightNature(); public IService getFnService() { return fnService; } public void setFnService(IService fnService) { this.fnService = fnService; } public List<FlightNature> getFnLists() { return fnLists; } public void setFnLists(List<FlightNature> fnLists) { this.fnLists = fnLists; } @SuppressWarnings("unchecked") public String list() throws Exception { //如果这样写会报NPE,即fnService没注入成功,但我把整段程序中的fnService改为iService,并改下配置文件就一切正常了 this.fnLists = this.fnService.loadAll(FlightNature.class); return SUCCESS; } public FlightNature getModel() { return this.fnBean; } }[/code] 本人spring菜鸟,多多指教。。。

关于spring框架当取消bean标签默认的单例模式时多创建出来的对象是怎么来的?

今天本来在测试spel spring表达式赋值的,但是突然发现了一些问题,想请教一下大家, 这是我在测试时观察表达式传值时方便查看用this显示对象地址,区分到底是那个对象进入了方法,类名就是Users,就是一个普通的get/set方法 ``` public String getName() { System.out.println("getname"+"="+this); return name; } public void setName(String name) { System.out.println("setname"+"="+this); this.name = name; } ``` 但是当我使用spring框架在spring.xml文件中做spel spring表达式赋值练习时为了确认是否传值,把默认的单例模式取消掉了,为如下代码: ``` <bean id="u1" class="com.qf.bean.Users" scope="prototype"> <property name="name" value="张三"></property> <property name="age" value="15"></property> </bean> <bean id="u2" class="com.qf.bean.Users"> <property name="name" value="#{u1.name}"></property> <property name="age" value="#{u1.age}"></property> </bean> <bean id="u3" class="com.qf.bean.Users"> <property name="name" value="#{u1.name}"></property> <property name="age" value="#{u1.age}"></property> </bean> ``` u3是为了测试u1改为了多例后u2和u3的地址是否相同用的,可以不看,然后我在测试类中准备打印对象的属性观察是否成功赋值,写了如下代码,怎么看都是没有问题的 ``` ApplicationContext app = new ClassPathXmlApplicationContext("spring.xml"); Users u1 = (Users) app.getBean("u1"); Users u2 = (Users) app.getBean("u2"); Users u3 = (Users) app.getBean("u3"); System.out.println("================"); System.out.println("u1 = " + u1); System.out.println(u1.getName() + "\t" + u1.getAge()); System.out.println("================"); System.out.println("u2 = " + u2); System.out.println(u2.getName() + "\t" + u2.getAge()); System.out.println("================"); System.out.println("u3 = " + u3); System.out.println(u3.getName() + "\t" + u3.getAge()); ``` 但是打印结果让我想不通为什么:结果为下述情况: ``` /*疑问 没有此对象 setname=com.qf.bean.Users@5c5a1b69 getname=com.qf.bean.Users@5c5a1b69 没有此对象 setname=com.qf.bean.Users@cd2dae5 u2 setname=com.qf.bean.Users@3a883ce7 没有此对象 setname=com.qf.bean.Users@79be0360 getname=com.qf.bean.Users@79be0360 没有此对象 setname=com.qf.bean.Users@22a67b4 u3 setname=com.qf.bean.Users@57855c9a u1 setname=com.qf.bean.Users@d44fc21 ================ u1 = com.qf.bean.Users@d44fc21 getname=com.qf.bean.Users@d44fc21 张三 15 ================ u2 = com.qf.bean.Users@3a883ce7 getname=com.qf.bean.Users@3a883ce7 张三 15 ================ u3 = com.qf.bean.Users@57855c9a getname=com.qf.bean.Users@57855c9a 张三 15 */ ``` 我是想问的我只有三个对象,走的<property name="name" value="#{u1.name}"></property>也应该是取一次值赋一次值,走一次get走一次set啊,为什么控制台输出的this地址会出来四个没用到也没出现的对象地址, 正常我三个对象,第一个应该直接走set赋值,第二个对象通过get获取第一个对象的值再set给自己,第三个也一样,那应该是走两次get方法,三次set方法,那么另外那么多次的getset方法是谁调用的?this的地址与我的三个对象地址完全不一样,那些地址是谁的?另外那四个我标注的看地址本应该不存在的地址对应的对象是怎么出来的?哪位大神能帮我说明一下,另外那四个对象是怎么来的?

Struts2+hibernate+spring事务配置没起作用

struts.xml <br /><pre name="code" class="java"> &lt;action name="index" class="indexAction"&gt; &lt;result name="success"&gt;/top5w.jsp&lt;/result&gt; &lt;/action&gt; </pre> <br /> <br />applicationContext.xml <br /><pre name="code" class="java"> &lt;bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"&gt; &lt;property name="driverClassName"&gt;&lt;value&gt;com.mysql.jdbc.Driver&lt;/value&gt;&lt;/property&gt; &lt;property name="url"&gt;&lt;value&gt;jdbc:mysql://localhost:3306/te&lt;/value&gt;&lt;/property&gt; &lt;property name="username"&gt;&lt;value&gt;root&lt;/value&gt;&lt;/property&gt; &lt;property name="password"&gt;&lt;value&gt;root&lt;/value&gt;&lt;/property&gt; &lt;property name="maxActive"&gt;&lt;value&gt;100&lt;/value&gt;&lt;/property&gt; &lt;property name="maxIdle"&gt;&lt;value&gt;20&lt;/value&gt;&lt;/property&gt; &lt;property name="maxWait"&gt;&lt;value&gt;100&lt;/value&gt;&lt;/property&gt; &lt;/bean&gt; &lt;bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"&gt; &lt;property name="dataSource" ref="dataSource" /&gt; &lt;property name="hibernateProperties"&gt; &lt;props&gt; &lt;prop key="hibernate.dialect"&gt;org.hibernate.dialect.MySQLDialect&lt;/prop&gt; &lt;prop key="hibernate.show_sql"&gt;true&lt;/prop&gt; &lt;/props&gt; &lt;/property&gt; &lt;property name="mappingLocations"&gt; &lt;list&gt; &lt;value&gt;classpath:com/zhang/tao/model/*.hbm.xml&lt;/value&gt; &lt;/list&gt; &lt;/property&gt; &lt;/bean&gt; &lt;bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"&gt; &lt;property name="sessionFactory" ref="sessionFactory" /&gt; &lt;/bean&gt; &lt;bean id="indexAction" class="com.zhang.struts.action.IndexAction" scope="prototype"&gt; &lt;property name="wordService" ref="kwordService" /&gt; &lt;/bean&gt; &lt;bean id="kwordService" class="com.zhang.struts.service.KwordService"&gt; &lt;property name="sessionFactory" ref="sessionFactory" /&gt; &lt;/bean&gt; </pre> <br /> <br />KwordService.java <br /><pre name="code" class="java"> private SessionFactory sessionFactory; public SessionFactory getSessionFactory() { return sessionFactory; } public void setSessionFactory(SessionFactory sessionFactory) { this.sessionFactory = sessionFactory; } public List&lt;?&gt; getResult(String hql,int currPage){ // Session session = sessionFactory.openSession(); Session session = sessionFactory.getCurrentSession(); Transaction tr = session.beginTransaction(); Query query = session.createQuery(hql); query.setFirstResult(50*currPage); query.setMaxResults(50); List&lt;?&gt; list = query.list(); tr.commit(); // session.close(); return list; } </pre> <br /> <br />IndexAction.java <br /><pre name="code" class="java"> private KwordService wordService; public String toIndex(){ HttpServletRequest request = ServletActionContext.getRequest(); List&lt;?&gt; list = null; String hql = "from com.zhang.tao.model.Kword"; list = wordService.getResult(hql,1); </pre> <br /> <br />如果在KwordService.java里用sessionFactory.openSession()就OK,但用getCurrentSession()就报错 <br />如果在kwordservice类里使用session = sessionFactory.openSession();就OK,如果使用getCurrentSession()就报错 <br />org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here <br />

java Spring scope设置为prototype,为什么两次生成的都是同一个实例

CurrentTime.java ``` import java.util.Calendar; public class CurrentTime { private Calendar now=Calendar.getInstance(); public void printCurrentTime() { System.out.println(now.getTime()); } } ``` ----------------------------------------------- lookup.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" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd"> <bean id="currentTime" class="cn.hxex.springcore.lookup.CurrentTime" scope="prototype"></bean> <bean id="lookupBean" class="cn.hxex.springcore.lookup.LookupBean" scope="singleton"> <lookup-method name="createCurrentTime" bean="currentTime"></lookup-method> <property name="currentTime" ref="currentTime"></property> </bean> </beans> ``` ------------------------------------------- LookupMain.java ``` import org.springframework.beans.factory.xml.XmlBeanFactory; import org.springframework.core.io.ClassPathResource; public class LookupMain { public static void main(String[] args) throws InterruptedException { // TODO Auto-generated method stub ClassPathResource resource=new ClassPathResource("cn/hxex/springcore/lookup/LookupBeans.xml"); XmlBeanFactory factory=new XmlBeanFactory(resource); // LookupBean lookupBean=(LookupBean) factory.getBean("lookupBean"); // System.out.println("get"); // lookupBean.getCurrentTime().printCurrentTime(); // System.out.println("create"); // lookupBean.createCurrentTime().printCurrentTime(); // System.out.println("------------"); // Thread.sleep(1000); // System.out.println("get"); // lookupBean.getCurrentTime().printCurrentTime(); // System.out.println("create"); // lookupBean.createCurrentTime().printCurrentTime(); // System.out.println("-----------"); CurrentTime ct=(CurrentTime) factory.getBean("currentTime"); System.out.println("一"); ct.printCurrentTime(); System.out.println("-----------"); Thread.sleep(5000); System.out.println("二"); ct.printCurrentTime(); } } ``` ![两次生成的实例是一样的](https://img-ask.csdn.net/upload/201911/19/1574165172_57674.png)

Tomcat启动时,卡在了spring创建bean的地方,请问该怎么解决?

项目整合了struts2,spring,hibernate,最近启动项目的时候经常跑 不起来,但有时又可以,可是今晚就老是跑不起来,下面是最后的几行日志,求大神赐教: 十一月 30, 2017 10:35:13 下午 org.apache.catalina.core.ApplicationContext log INFO: Initializing Spring root WebApplicationContext 2017-11-30 22:35:13,935 INFO (org.springframework.web.context.ContextLoader:187) - Root WebApplicationContext: initialization started 2017-11-30 22:35:14,208 INFO (org.springframework.web.context.support.XmlWebApplicationContext:456) - Refreshing Root WebApplicationContext: startup date [Thu Nov 30 22:35:14 CST 2017]; root of context hierarchy 2017-11-30 22:35:14,567 INFO (org.springframework.beans.factory.xml.XmlBeanDefinitionReader:315) - Loading XML bean definitions from ServletContext resource [/WEB-INF/applicationContext.xml] 2017-11-30 22:35:15,601 INFO (org.springframework.beans.factory.support.DefaultListableBeanFactory:555) - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@5bed0458: defining beans [dataSource,sessionFactory,HibernateConfig,baseDao,loginService,goodService,wsMsgService,LoginAction,WsMsgAction,GoodAction]; root of factory hierarchy 我的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" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"> <!-- <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> --> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName"> <value>com.mysql.jdbc.Driver</value> </property> <property name="url"> <value>jdbc:mysql://localhost:3506/xmesdb</value> </property> <property name="username"> <value>root</value> </property> <property name="password"> <value>123456</value> </property> </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource"> <ref local="dataSource"/> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect"> org.hibernate.dialect.MySQLDialect </prop> <prop key="hibernate.show_sql">true</prop> <prop key="hibernate.hbm2ddl.auto">update</prop> <prop key="hibernate.current_session_context_class">thread</prop> </props> </property> <property name="mappingResources"> <list> <value>com/model/User.hbm.xml</value> <value>com/model/WsMsg.hbm.xml</value> <value>com/model/GoodMobilePhone.hbm.xml</value> <value>com/model/GoodBook.hbm.xml</value> <value>com/model/GoodComputer.hbm.xml</value> <value>com/model/GoodMobike.hbm.xml</value> </list> </property> </bean> <bean id="HibernateConfig" class="com.hibernate.HibernateConfig"> <property name="sessionFactory"> <ref local="sessionFactory"/> </property> </bean> <bean id="baseDao" class="com.dao.BaseDaoImpl" scope="prototype"> <property name="sessionFactory"> <ref local="sessionFactory"/> </property> </bean> <bean id="loginService" class="com.service.impl.LoginServiceImpl" scope="prototype"> <property name="baseDao"> <ref local="baseDao"/> </property> </bean> <bean id='goodService' class="com.service.impl.GoodServiceImpl" scope="prototype"> <property name="baseDao"> <ref local="baseDao"/> </property> </bean> <bean id="wsMsgService" class="com.webSocket.Service.impl.WsMsgServiceImpl" scope="prototype"> </bean> <bean id="LoginAction" class="com.action.LoginAction" scope="prototype"> <property name="baseDao" ref="baseDao"></property> <property name="loginService" ref="loginService"></property> <property name="wsMsgService" ref="wsMsgService"></property> </bean> <bean id="WsMsgAction" class="com.action.WsMsgAction" scope="prototype"> <property name="wsMsgService" ref="wsMsgService"></property> </bean> <bean id="GoodAction" class="com.action.GoodAction" scope="prototype"> <property name="goodService" ref="goodService"></property> </bean> </beans> 菜鸟一枚,求教求教

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

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

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

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

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

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

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

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

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

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

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

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

为什么本科以上学历的人只占中国人口的5%,但感觉遍地都是大学生?

中国大学生占总人口不到5% 2017年,中国整体的本科率仅有5.9%;如果算上研究生,这一比例可以进一步上升到6.5% 为什么在国家统计局推出的这份年鉴中,学历的最高一阶就是到研究生,而没有进一步再统计博士生的数量的。 原因其实并不难理解,相比全国和各省整体人口体量,博士生的占比非常之低,属于绝对意义上的小概率样本。 这一点,我们从上表中的各省研究生占比情况也可以看出端倪。除北京、天津、上海三...

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

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

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

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

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

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

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

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

程序员写出这样的代码,能不挨骂吗?

当你换槽填坑时,面对一个新的环境。能够快速熟练,上手实现业务需求是关键。但是,哪些因素会影响你快速上手呢?是原有代码写的不够好?还是注释写的不够好?昨夜...

外包程序员的幸福生活

今天给你们讲述一个外包程序员的幸福生活。男主是Z哥,不是在外包公司上班的那种,是一名自由职业者,接外包项目自己干。接下来讲的都是真人真事。 先给大家介绍一下男主,Z哥,老程序员,是我十多年前的老同事,技术大牛,当过CTO,也创过业。因为我俩都爱好喝酒、踢球,再加上住的距离不算远,所以一直也断断续续的联系着,我对Z哥的状况也有大概了解。 Z哥几年前创业失败,后来他开始干起了外包,利用自己的技术能...

带了6个月的徒弟当了面试官,而身为高级工程师的我天天修Bug......

即将毕业的应届毕业生一枚,现在只拿到了两家offer,但最近听到一些消息,其中一个offer,我这个组据说客户很少,很有可能整组被裁掉。 想问大家: 如果我刚入职这个组就被裁了怎么办呢? 大家都是什么时候知道自己要被裁了的? 面试软技能指导: BQ/Project/Resume 试听内容: 除了刷题,还有哪些技能是拿到offer不可或缺的要素 如何提升面试软实力:简历, 行为面试,沟通能...

优雅的替换if-else语句

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

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

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

记录下入职中软一个月(外包华为)

我在年前从上一家公司离职,没想到过年期间疫情爆发,我也被困在家里,在家呆着的日子让人很焦躁,于是我疯狂的投简历,看面试题,希望可以进大公司去看看。 我也有幸面试了我觉得还挺大的公司的(虽然不是bat之类的大厂,但是作为一名二本计算机专业刚毕业的大学生bat那些大厂我连投简历的勇气都没有),最后选择了中软,我知道这是一家外包公司,待遇各方面甚至不如我的上一家公司,但是对我而言这可是外包华为,能...

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

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

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

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

面试:第十六章:Java中级开发

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

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

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

Python爬虫,高清美图我全都要(彼岸桌面壁纸)

爬取彼岸桌面网站较为简单,用到了requests、lxml、Beautiful Soup4

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

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

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

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

6年开发经验女程序员,面试京东Java岗要求薪资28K

写在开头: 上周面试了一位女程序员,上午10::30来我们部门面试,2B哥接待了她.来看看她的简历: 个人简历 个人技能: ● 熟悉spring mvc 、spring、mybatis 等框架 ● 熟悉 redis 、rocketmq、dubbo、zookeeper、netty 、nginx、tomcat、mysql。 ● 阅读过juc 中的线程池、锁的源...

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

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

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

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

Java岗开发3年,公司临时抽查算法,离职后这几题我记一辈子

前几天我们公司做了一件蠢事,非常非常愚蠢的事情。我原以为从学校出来之后,除了找工作有测试外,不会有任何与考试有关的事儿。 但是,天有不测风云,公司技术总监、人事总监两位大佬突然降临到我们事业线,叫上我老大,给我们组织了一场别开生面的“考试”。 那是一个风和日丽的下午,我翘着二郎腿,左手端着一杯卡布奇诺,右手抓着我的罗技鼠标,滚动着轮轴,穿梭在头条热点之间。 “淡黄的长裙~蓬松的头发...

大牛都会用的IDEA调试技巧!!!

导读 前天面试了一个985高校的实习生,问了他平时用什么开发工具,他想也没想的说IDEA,于是我抛砖引玉的问了一下IDEA的调试用过吧,你说说怎么设置断点...

都前后端分离了,咱就别做页面跳转了!统统 JSON 交互

文章目录1. 无状态登录1.1 什么是有状态1.2 什么是无状态1.3 如何实现无状态1.4 各自优缺点2. 登录交互2.1 前后端分离的数据交互2.2 登录成功2.3 登录失败3. 未认证处理方案4. 注销登录 这是本系列的第四篇,有小伙伴找不到之前文章,松哥给大家列一个索引出来: 挖一个大坑,Spring Security 开搞! 松哥手把手带你入门 Spring Security,别再问密...

立即提问
相关内容推荐