spring 프로필 상세 설명

1. 기본 설정:
<?xml version="1.0" encoding="UTF-8"?>
<beans
	xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:context="http://www.springframework.org/schema/context"
	xsi:schemaLocation="http://www.springframework.org/schema/beans 
	                   http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
	                   http://www.springframework.org/schema/context
	                   http://www.springframework.org/schema/context/spring-context-2.5.xsd
	                   ">


<context:component-scan base-package="com.persia">
<!--        -->
</context:component-scan>

<context:annotation-config>
<!--       -->
</context:annotation-config>

<!--     ,   propertity xml  ,  xml     -->
<bean id="personServiceAnno" class="com.persia.PersonServiceAnnotation"></bean>
<bean id="personDaoBeanAnno" class="com.persia.PersonDaoBean"></bean>
<bean id="personDaoBeanAnno2" class="com.persia.PersonDaoBean"></bean>

<!--      -->
<bean id="personServiceAutoInject" class="com.persia.PersonServiceAutoInject" autowire="byName"></bean>


<bean id="personService" class="com.persia.PersonServiceBean">
<!--  spring        ,           -->
</bean>

<bean id="personService2" class="com.persia.PersonServiceBeanFactory" factory-method="createInstance" lazy-init="true" 
      init-method="init"  destroy-method="destory">
<!--       bean -->
</bean>

<bean id="fac" class="com.persia.PersonServiceBeanInsFactory"></bean>
<bean id="personService3" factory-bean="fac" factory-method="createInstance" scope="prototype">
<!--       bean,          bean-->
</bean>


<!-- ref       -->
<bean id="personDao" class="com.persia.PersonDaoBean"></bean>
<bean id="personService4" class="com.persia.PersonServiceBean">
  <property name="personDao" ref="personDao"></property>
</bean>

<!--   bean     -->
<bean id="personService5" class="com.persia.PersonServiceBean">
  <property name="personDao">
     <bean class="com.persia.PersonDaoBean"></bean>
  </property>
  <property name="name" value="persia"></property>
  <property name="age" value="21"></property>
  
  <property name="sets">
    <!--       -->
     <set>
       <value>   </value>
       <value>   </value>
       <value>   </value>
     </set>
  </property>
  
  <property name="lists">
    <!--       -->
    <list>
        <value>   l</value>
       <value>   l</value>
       <value>   l</value>
    </list>
    
  </property>
  
  <property name="properties">
    <props>
      <prop key="key1">value1</prop>
      <prop key="key2">value2</prop>
      <prop key="key3">value3</prop>
    </props>
  </property>
  
  <property name="map">
   <map>
      <entry key="key1" value="value-1"></entry>
      <entry key="key2" value="value-2"></entry>
      <entry key="key3" value="value-3"></entry>
   </map>
  </property>
</bean>

<bean id="personService6" class="com.persia.PersonServiceBean">
   <constructor-arg index="0" value="     name" ></constructor-arg>
   <!--         type -->
   <constructor-arg index="1" type="com.persia.IDaoBean" ref="personDao">
   </constructor-arg> 
</bean>

</beans>

2. AOP 오픈:
<?xml version="1.0" encoding="UTF-8"?>
<beans
	xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns:aop="http://www.springframework.org/schema/aop"
	xsi:schemaLocation="http://www.springframework.org/schema/beans 
	                   http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
	                    http://www.springframework.org/schema/aop
	                   http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
	                   http://www.springframework.org/schema/context
	                   http://www.springframework.org/schema/context/spring-context-2.5.xsd
	                  ">

<aop:aspectj-autoproxy></aop:aspectj-autoproxy>
<bean id="myInterceptor" class="com.persia.service.MyInterceptor"></bean>
<bean id="personServiceImpl" class="com.persia.service.impl.PersonServiceImpl"></bean>
</beans>
AOP xml  
<?xml version="1.0" encoding="UTF-8"?>
<beans
	xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns:aop="http://www.springframework.org/schema/aop"
	xsi:schemaLocation="http://www.springframework.org/schema/beans 
	                   http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
	                    http://www.springframework.org/schema/aop
	                   http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
	                   http://www.springframework.org/schema/context
	                   http://www.springframework.org/schema/context/spring-context-2.5.xsd
	                  ">

<aop:aspectj-autoproxy></aop:aspectj-autoproxy>

<bean id="personService" class="com.persia.service.impl.PersonServiceImpl"></bean>
<bean id="aspectBean" class="com.persia.service.MyInterceptor"></bean>

<aop:config>
 <aop:aspect id="myaop" ref="aspectBean">
 <aop:pointcut id="mycut" expression="execution(* com.persia.service.impl.PersonServiceImpl.*(..))"/>
 <aop:pointcut id="argcut" expression="execution(* com.persia.service.impl.PersonServiceImpl.*(..)) and args(name)"/>  
 <aop:before pointcut-ref="mycut" method="doAccessCheck"  />
 <aop:after-returning pointcut-ref="mycut" method="doAfterReturning"/>
   <aop:after-throwing pointcut-ref="mycut" method="doThrowing"/>
   <aop:after pointcut-ref="argcut" method="doAfter" arg-names="name"/>
 <aop:around pointcut-ref="mycut" method="arround"/>
 </aop:aspect>
  
</aop:config>

</beans>
3.       :
<?xml version="1.0" encoding="UTF-8"?>
<beans
	xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns:aop="http://www.springframework.org/schema/aop"
	xmlns:tx="http://www.springframework.org/schema/tx" 
	xsi:schemaLocation="http://www.springframework.org/schema/beans 
	                   http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
	                   http://www.springframework.org/schema/context
	                   http://www.springframework.org/schema/context/spring-context-2.5.xsd
	                   http://www.springframework.org/schema/aop
	                   http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
	                   http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd 
	                  ">

<aop:aspectj-autoproxy></aop:aspectj-autoproxy>
	                  
<!--       -->   
  <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">   
    <property name="driverClassName" value="com.mysql.jdbc.Driver"/>   
    <property name="url" value="jdbc:mysql://localhost:3306/test?useUnicode=true&amp;characterEncoding=utf-8"/>   
    <property name="username" value="root"/>   
    <property name="password" value=""/>   
     <!--            -->   
     <property name="initialSize" value="1"/>   
     <!--         -->   
     <property name="maxActive" value="500"/>   
     <!--      .          ,                       ,     maxIdle   -->   
     <property name="maxIdle" value="2"/>   
     <!--       .            ,             ,            -->   
     <property name="minIdle" value="1"/>   
  </bean>  
   
  <!--        -->   
 <bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">   
    <property name="dataSource" ref="dataSource"/>   
  </bean>  
  <!--     bean -->
    <bean id="personService" class="com.persia.service.impl.PersonServiceImpl">
    <property name="ds" ref="dataSource"></property>
  </bean>
   
  <!--   @Transactional          -->   
  <tx:annotation-driven transaction-manager="txManager"/>  


</beans>

XML 버 전:
<?xml version="1.0" encoding="UTF-8"?>
<beans
	xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns: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.5.xsd
	                   http://www.springframework.org/schema/context
	                   http://www.springframework.org/schema/context/spring-context-2.5.xsd
	                   http://www.springframework.org/schema/aop
	                   http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
	                   http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd 
	                  ">

<aop:aspectj-autoproxy></aop:aspectj-autoproxy>
	                  
<!--       -->   
  <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">   
    <property name="driverClassName" value="com.mysql.jdbc.Driver"/>   
    <property name="url" value="jdbc:mysql://localhost:3306/test?useUnicode=true&amp;characterEncoding=utf-8"/>   
    <property name="username" value="root"/>   
    <property name="password" value=""/>   
     <!--            -->   
     <property name="initialSize" value="1"/>   
     <!--         -->   
     <property name="maxActive" value="500"/>   
     <!--      .          ,                       ,     maxIdle   -->   
     <property name="maxIdle" value="2"/>   
     <!--       .            ,             ,            -->   
     <property name="minIdle" value="1"/>   
  </bean>  
   
<!--         -->
 <bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">   
    <property name="dataSource" ref="dataSource"/>   
  </bean>  
  <!--     bean -->
   <bean id="personService" class="com.persia.service.impl.PersonServiceImpl">
    <property name="ds" ref="dataSource"></property>
  </bean>
  
  
    <!--   XML       -->  
<aop:config>  
    <!--       ,           -->   
    <aop:pointcut id="transactionPointcut" expression="execution(* com.persia.service..*.*(..))"/>  
    <aop:advisor advice-ref="txAdvice" pointcut-ref="transactionPointcut"/>  
</aop:config> 
<!--          -->    
<tx:advice id="txAdvice" transaction-manager="txManager">  
      <tx:attributes> 
      <!--    get   ,      --> 
        <tx:method name="get*" read-only="true" propagation="NOT_SUPPORTED"/> 
      <!--             --> 
        <tx:method name="*"/>  
      </tx:attributes>  
</tx:advice>  
   
  
</beans>

4.SSH:
<?xml version="1.0" encoding="UTF-8"?>
<beans
	xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns:aop="http://www.springframework.org/schema/aop"
	xmlns:tx="http://www.springframework.org/schema/tx" 
	xsi:schemaLocation="http://www.springframework.org/schema/beans 
	                   http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
	                   http://www.springframework.org/schema/context
	                   http://www.springframework.org/schema/context/spring-context-2.5.xsd
	                   http://www.springframework.org/schema/aop
	                   http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
	                   http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd 
	                  ">


	<!--       -->   
  <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">   
    <property name="driverClassName" value="com.mysql.jdbc.Driver"/>   
    <property name="url" value="jdbc:mysql://localhost:3306/test?useUnicode=true&amp;characterEncoding=utf-8"/>   
    <property name="username" value="root"/>   
    <property name="password" value=""/>   
     <!--            -->   
     <property name="initialSize" value="1"/>   
     <!--         -->   
     <property name="maxActive" value="500"/>   
     <!--      .          ,                       ,     maxIdle   -->   
     <property name="maxIdle" value="2"/>   
     <!--       .            ,             ,            -->   
     <property name="minIdle" value="1"/>   
  </bean>  
  
  <!--   hibernate sessionFactory -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
	<property name="dataSource"><ref bean="dataSource" /></property>
	 <property name="mappingResources">
		    <list>
		      <value>com/persia/model/Person.hbm.xml</value>
		    </list>
		 </property>
		 
	    <!-- 1.   sessionFactory      3    -->
        <!-- 2.             ehcache.xml        -->
        <!-- 3.           bean              -->
             <!--      --> 
             <!--        ,          --> 
             <!--   Ehcache     -->  
	 <property name="hibernateProperties">
		    <value>
		        hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
		        hibernate.hbm2ddl.auto=update
		        hibernate.show_sql=false
		        hibernate.format_sql=false
		        hibernate.cache.use_second_level_cache=true
       	        hibernate.cache.use_query_cache=false
        	    hibernate.cache.provider_class=org.hibernate.cache.EhCacheProvider
		    </value>
	     </property>
</bean>

<!--   Spring  hibernate       -->
<bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
	  	<property name="sessionFactory" ref="sessionFactory"/>
</bean>

<!--                -->	
<tx:annotation-driven transaction-manager="txManager"/>

<!--               bean -->
<context:annotation-config></context:annotation-config>

<!--        bean -->
<bean id="personService" class="com.persia.service.impl.PersonServiceImpl"></bean>

<!-- Struts action  Spring      -->
<bean name="/person/list" class="com.persia.struts.PersonListAction">
<!--1.    name struts-config   action path    ,  id        -->
<!--2.   Struts-config      Spring      ,       action path   Spring        bean,        bean        -->
<!--3.    action type    (  ), Spring       bean ,    Struts action-->
<!--4.   action    Spring          bean-->
</bean>

<bean name="/person/manage" class="com.persia.struts.PersonManageAction"></bean>
</beans>

5.SSH2:
<?xml version="1.0" encoding="UTF-8"?>
<beans
	xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns:aop="http://www.springframework.org/schema/aop"
	xmlns:tx="http://www.springframework.org/schema/tx" 
	xsi:schemaLocation="http://www.springframework.org/schema/beans 
	                   http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
	                   http://www.springframework.org/schema/context
	                   http://www.springframework.org/schema/context/spring-context-2.5.xsd
	                   http://www.springframework.org/schema/aop
	                   http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
	                   http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd 
	                  ">


	<!--       -->   
  <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">   
    <property name="driverClassName" value="com.mysql.jdbc.Driver"/>   
    <property name="url" value="jdbc:mysql://localhost:3306/test?useUnicode=true&amp;characterEncoding=utf-8"/>   
    <property name="username" value="root"/>   
    <property name="password" value=""/>   
     <!--            -->   
     <property name="initialSize" value="1"/>   
     <!--         -->   
     <property name="maxActive" value="500"/>   
     <!--      .          ,                       ,     maxIdle   -->   
     <property name="maxIdle" value="2"/>   
     <!--       .            ,             ,            -->   
     <property name="minIdle" value="1"/>   
  </bean>  
  
  <!--   hibernate sessionFactory -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
	<property name="dataSource"><ref bean="dataSource" /></property>
	 <property name="mappingResources">
		    <list>
		      <value>com/persia/model/Person.hbm.xml</value>
		    </list>
		 </property>
		 
	    <!-- 1.   sessionFactory      3    -->
        <!-- 2.             ehcache.xml        -->
        <!-- 3.           bean              -->
             <!--      --> 
             <!--        ,          --> 
             <!--   Ehcache     -->  
	 <property name="hibernateProperties">
		    <value>
		        hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
		        hibernate.hbm2ddl.auto=update
		        hibernate.show_sql=false
		        hibernate.format_sql=false
		        hibernate.cache.use_second_level_cache=true
       	        hibernate.cache.use_query_cache=false
        	    hibernate.cache.provider_class=org.hibernate.cache.EhCacheProvider
		    </value>
	     </property>
</bean>

<!--   Spring  hibernate       -->
<bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
	  	<property name="sessionFactory" ref="sessionFactory"/>
</bean>

<!--                -->	
<tx:annotation-driven transaction-manager="txManager"/>

<!--               bean -->
<context:annotation-config></context:annotation-config>

<!--        bean -->
<bean id="personService" class="com.persia.service.impl.PersonServiceImpl"></bean>

<!--  Struts 2 action -->
<bean id="personList" class="com.persia.struts2.action.PersonListAction"></bean>
</beans>

6.SSJ:
<?xml version="1.0" encoding="UTF-8"?>
<beans
	xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns:aop="http://www.springframework.org/schema/aop"
	xmlns:tx="http://www.springframework.org/schema/tx" 
	xsi:schemaLocation="http://www.springframework.org/schema/beans 
	                   http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
	                   http://www.springframework.org/schema/context
	                   http://www.springframework.org/schema/context/spring-context-2.5.xsd
	                   http://www.springframework.org/schema/aop
	                   http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
	                   http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd 
	                  ">


<!--               bean -->
<context:annotation-config></context:annotation-config>

<!-- 1.  Spring  JPA -->
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean">
      <property name="persistenceUnitName" value="SpringJPAPU"/>
</bean>

<!--2.  Spring  JPA    -->
    <bean id="txManager" class="org.springframework.orm.jpa.JpaTransactionManager">
  	  <property name="entityManagerFactory" ref="entityManagerFactory"/>
</bean>

<!--3.       -->
<tx:annotation-driven transaction-manager="txManager"/>
  
<!--  3 Spring  JPA   , web     Spring  ,   JPA         -->

<!--     bean -->
<bean id="personService" class="com.persia.service.impl.PersonServiceImpl"></bean>

<!--   Struts action -->
<bean name="/person/list" class="com.persia.struts.PersonListAction"/>
<bean name="/person/manage" class="com.persia.struts.PersonManageAction"/>
</beans>

좋은 웹페이지 즐겨찾기