struts2.3.24 + spring4.1.6 + hibernate4.3.11 + mysql5.5.25 개발 환경 구성 및 관련 지침.
1. 목표
1. 전통적인 SSH 개발 환경을 구축하고 성공적으로 실행하십시오 (삽입, 쿼리).
2. C3P0 연결 풀의 구성을 이해하십시오
3. 최대 절전 모드의 보조 캐시를 이해하고 확인하십시오
4. 스프링 물건의 구성을 이해하고 확인하십시오
5. Spring 's IOC (종속성 주입)를 이해하고 STRUTS2의 액션 객체 (BEAN)를 스프링 관리, 사용자 정의 Bean 등으로 넘겨주고 확인하십시오.
6. Spring AOP (섹션 지향 프로그래밍)를 이해하고 결과를 확인하기 위해 사용자 정의 섹션 기능을 작성하십시오.
2. 준비
개발 환경 : Java EE의 일식; mysql5.5.25; JDK1.7.0_79; NAVICAT10.1.7 (선택 사항);
데이터베이스 데모 생성 :
/*Navicat MySQL 데이터 트랜스퍼 소스 서버 : LocalHost_3306Source 서버 버전 : 50519Source 호스트 : LocalHost : 3306Source 데이터베이스 : Demotarget 서버 유형 : MySQLTARGET 서버 버전 : 50519File alcoding : 65001Date : 2016-01-09 23 : 02*/set key_checks = 02. --------------------------`사용자 '를위한 테이블 구조--------------------------------------------------------------------------------------------------``user' '(``varch (20)가 null auto_increment,`ac 기본 charset = utf8;
새로운 웹 프로젝트를 작성하십시오. 디렉토리 구조는 다음과 같습니다.
JAR 패키지를 준비하고 Web-INF LIB 디렉토리에 넣습니다 (관심이 있으시면 Maven을 사용하여 프로세스를 관리 할 수 있지만 때로는 JAR 패키지를 다운로드하는 데 매우 느립니다 ...)
관련 JAR 패키지는 다운로드 된 스트럿, 스프링 및 최대 절전 모드에서 찾을 수 있습니다. 여기에 참조가 있습니다. 스프링 MVC 부분의 JAR 패키지와 같이 일부는 삭제할 수 있습니다.
3. Web.xml을 구성하십시오
struts2 필터를 구성하여 모든 *.action 요청을 매핑하고 strutsprepareandexecutefilter 객체에 의해 처리됩니다.
Context-Param 매개 변수를 구성하고 스프링 구성 파일의 경로를 지정하십시오. <CERTXT-PARAM>의 매개 변수는 servletContext.getInitParameter ( "param-name")를 사용하여 얻을 수 있습니다.
청취자 구성은 주로 ApplicationContext.xml 구성 파일 정보를 읽고 Bean 및 기타 초기화 작업을 작성하는 것입니다.
<? xml version = "1.0"encoding = "utf-8"?> <web-app xmlns : xsi = "http://www.w3.org/2001/xmlschema-instance"xmlns = "http://java.sun.com/xml/ns/javaee" xsi : schemalocation = "http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_3_0.xsd"3. ""webapp_ "" " <display-name> ssh </display-name> <filter> <filter-name> struts2 </filter-name> <filter-class.apache.struts2.dispatcher.ng.filter.strutsprepareanDexecuteFilter </filter-class> </filter> <filter-name> struts2 </filter-name> <Url-Pattern>*. Action </url-pattern> </filter-mapping> <context-param> <param-name> contextConfigLocation </param-name> <param- value> classpath : ApplicationContext.xml </param- value> </context-param> <layer> <Leater-Class> org.springframework.web.context.contextloaderListener </Learter-Class> </Listener> <Welcome-File-List> <welce-file> index.jsp </welcome-file> </welcle-file-list> </web-app>
4. ApplicationContext.xml을 구성합니다
SSH 패키지 아래에서 @repostory, @service 및 기타 주석의 자동 스캔을 구성하고 해당 콩을 생성합니다.
데이터 소스 구성 (JDBC 연결 풀은 C3P0입니다. C3P0의 세부 구성을 참조 할 수 있음). 연결 풀의 주요 기능은 연결을 신속하게 제공하고 재사용하는 것입니다. 각 파괴와 창조가 필요하지 않습니다. 사용자 이름, 비밀번호, 최대 연결 수, 최소 연결 수, 초기 연결 수 및 기타 관련 매개 변수 구성이 필요합니다.
SessionFactory 구성 (레벨 2 캐시를 활성화하도록 구성하는 최대적인 구성을 참조 할 수 있습니다). 기본 기능은 세션을 제공하고 SQL 문을 실행하는 것입니다. 여기서 우리는 HibernateTemplate를 사용하여 스프링의 물리적 제어를 용이하게하기 위해 데이터베이스를 작동합니다. 추신, 클래스와 데이터베이스 테이블 간의 매핑은 최대 절전 모드 구성에서 구성되어야합니다.
트랜잭션 관리자 Bean을 HiberNateTransactionManager로 구성하고 이전에 구성된 SessionFactory Bean에 멤버 속성 SessionFactory를 초기화하십시오.
트랜잭션의 전파 특성을 구성하고이를 참조 할 섹션을 구성하고 모든 SSH.Ssh.service 패키지 및 하위 포장에서 모든 추가, 삭제, 업데이트 및 저장의 트랜잭션 제어를 수행하십시오. 트랜잭션 전파 동작 및 기타 매개 변수를 구성 할 수도 있습니다.
마지막으로, 사용자 정의 AOP 관련 구성이 있는데,이 구성은 SSH.AOP.AOPTEST에서 테스트로 시작하는 모든 방법을 제어하기 위해 사용자 정의 섹션 'MyAOP'를 적용하며 결과는 나중에 확인됩니다.
<? xml version = "1.0"encoding = "utf-8"?> <beans xmlns = "http://www.springframework.org/schema/beans"xmlns : p = "http://www.springframework.org/schema/p" xmlns : context = "http://www.springframework.org/schema/context"xmlns : tx = "http://www.springframework.org/schema/tx"xmlns : xsi = "http://www.w.w.w.org/2001/xmlsmemal xmlns : aop = "http://www.springframework.org/schema/aop"xmlns : jdbc = "http://www.springframework.org/schema/jdbc"xsi : schemalocation = "http://wwww.spremegramew.sprameworw.spramework.gramwerk.s http://www.springframework.org/schema/beans http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop http://wwww.springframework.org/schema/schema/spridatsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.1.xsd http://www.spramework.org/schema/jdbc http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-4.1.xsd http://www.springframework.org/schema/screma/sprem/context-4.1 <!-주석이 달린 구성 요소에 대한 클래스 경로를 스캔합니다 (스프링 콩으로 자동 등록 할 @repostory 및 @Service 포함-> <context : component-scan base-package = "ssh" /> <!-지원 데이터 소스-> <bean name = "dataSource"destroy-method = "close"> <property name = "jdbcurl"value = "jdbc : mysql : // localhost : 3306/demo"/> <property name = "user"value = "root"/> <property name = "valess"/> <속성 이름 = "arevireIncrement"value = "1"> </property> <Property name = "80"> ">"> 이름 = "maxIdletime"value = "60"> </propert> <속성 이름 = "maxpoolsize"value = "80"> </property> <속성 이름 = "minpoolsize"value = "30"> </property> <속성 이름 = "acquireretreticdelay"value = "1000"> </property name = "arcideretretyattempts"60 "> </propertyatempts"60 ">"> 이름 = "breakfteracquirefailure"value = "false"> </propertion> <!-너무 많은 연결이 나타나면 mysql의 구성 파일 my.ini를 수정하려면 최대 연결 수를 늘리기 위해 (현재 연결 명령 : show processlist 참조)-> </bean> <bean> <속성 "> ref ="datasource "ref ="datasource " 이름 = "HibernateProperties"> <prop key = "hibernate.dialect"> org.hibernate.dialect.mysqldialect </prop> <prop key = "hibernate.show_sql"> true </prop> <prop key = "hibernate.hbm2ddl.auto"> 업데이트 </prop> <prop key = "current_session_context_class"> 스레드 </prop> <prop key = "hibernate.cache.use_second_level_cache"> true </prop> <prop key = "hibernate.cache.use_second_level_cache"> true </prop> <prop key = "hibernate.cache.region.factory_class"> org.hibernate.cache.ehcache.ehcacheregionfactory </prop> <prop key = "hibernate.cache.use_query_cache"> true </prop> <prop key = "hibernate.cache.provider_configuration_file_resource_path"> ehcache.xml </prop> </props> </props> </property name> <property name = "mappingLocations"> <slist> value> classPath : ssh/moder.hbm.xml </list> <! <slist> <sh.model.user </value> </value> </list> </property>-> </bean> <!-트랜잭션 관리자 구성-> <bean id = "transactionManager"> <property name = "sessionFactory"ref = "SessionActory"/</bean> <!-Transaction-Manager의 전파 특성 = "tx"> <tx : "TX :" 전파 = "필수"read-dony = "false"rollback-for = "java.lang.except"/> <tx : 메소드 이름 = "delete*"propagation = "필수"read-now = "false"rollback-for = "java.lang.excep"/<tx : method name = "update*"proplegation = "read folly ="false " rollback-for = "java.lang.exception"/> <tx : method name = "save*"propagation = "필수"read-doly = "false"rollback-for = "java.lang.exception"/> </tx> </tx : 조언> <aop : config> <aop : pcmethod (pcmethod) "=* ssh.service ..*.*(..)) "/> <aop : Advisor Pointcut-Ref ="pcmethod "Advice-Ref ="txadvice "/> </aop : config> <!-사용자 정의 AOP 처리 테스트-> <bean id ="aoptest "> </bean> <Bean id ="myaop "> <aop : 측면 ref = "myaop"> <aop : pointcut id = "pcmethodtest"expression = "execution (* ssh.aop.aoptest.test* (..))") "/> <aop : pointcut-ref ="pcmethodtes "method ="이전 "/> <aop : appointcut-ref ="> </aop : 측면> </aop : config> </beans>
5. struts.xml 구성
구조를 구성하십시오.
결과 유형을 "JSON"으로 구성하면 다른 것들을 구성 할 수도 있습니다. 여기서는 프론트 엔드 및 백엔드 데이터 상호 작용의 편의를 위해 JSON 형식으로 구성됩니다.
AddUser와 QueryAllUser의 두 가지 작업을 구성합니다.
<? xml version = "1.0"alcoding = "utf-8"?> <! doctype struts public "-// apache 소프트웨어 재단 // dtd struts configuration 2.3 // en" "http://struts.apache.org/dtds/struts-2.3.dtd "> <struts> <construt and <constant name =" "". 이름 = "struts.enable.dynamicmethodinvocation"value = "false" /> <constant name = "struts.devmode"value = "false" /> <package name = "default"extends = "Struts-default, json-default"> <global-results> <result type = "json"> <root "> json <param> <param> 이름 = "contentType"> text/html </param> </result> </global-Results> <action name = "adduser"method = "addUser"> </result> </action> <action name = "QueryAllUser"method = "queryAllUser"> <result> </package> <!-</struts adde-> </struts>
6. 관련 코드를 작성하십시오
참고 :
DAO는 Hibernatedaosupport 클래스를 상속하고 모든 데이터베이스 관련 작업은 HibernateTemplate에서 작동합니다.
DAO 레이어, 서비스 계층 및 동작에 해당 주석을 추가하고 스프링 콩으로 등록하십시오.
첨부 된 코드는 다음과 같습니다.
userAction.java
패키지 ssh.action; import java.io.printwriter; import java.util.list; import javax.annotation.resource; import javax.servlet.http.httpervletrequest; import javax.servlet.http.httpservletresponse; import org.apache.log4j.logger import org.apache.struts2.servletactioncontext; import org.springframework.stereotyp.controller; import ssh.aop.aoptest; import ssh.model.user; import ssh.service.userservice; import com.google.gson.gson; @controllerpublic class userservice {@controllerpublic class vosterservice { logger.getLogger (userAction.class); @Resource private userervice userervice; @Resource private aoptest aoptest; public void adduser () {printwriter out = null; {httpservletrequest request = servletactionContext.getRequest (); httpservletResponse 응답 = servletactionContext.getResponse (); Response.setContentType ( "Text/Html; charset = utf-8"); 문자열 계정 = request.getParameter ( "계정"); 문자열 이름 = request.getParameter ( "name"); 문자열 주소 = request.getParameter ( "주소"); 사용자 user = 새 사용자 (); user.setAccount (계정); user.setAddress (주소); user.setName (이름); userervice.add (user); out = response.getWriter (); out.write (New Gson (). Tojson ( "Success")); } catch (예외 e) {e.printstacktrace (); logger.error (e.getMessage ()); if (out! = null) out.write (new gson (). tojson ( "실패")); } 마침내 {out.flush (); out.close (); }} public void queryAllUser () {printwriter out = null; aoptest.test1 (); aoptest.test2 (); //logger.error("i "); {httpservletResponse 응답 = servletactionContext.getResponse (); Response.setContentType ( "Text/Html; charset = utf-8"); GSON GSON = NEW GSON (); List <user> userList = userErvice.queryAllUser (); 문자열 GSONST = GSON.TOJSON (userList); out = response.getWriter (); out.write (gsonst); } catch (예외 e) {e.printstacktrace (); logger.error (e.getMessage ()); if (out! = null) out.write (new gson (). tojson ( "실패")); } 마침내 {out.flush (); out.close (); }}}aoptest.java
package ssh.aop; public class aoptest {public void test1 () {system.out.println ( "aoptest test1 메서드가 실행 중 ~"); } public void test2 () {System.out.println ( "AOPTEST Test2가 실행 중 ~"); }}myaop.java
package ssh.aop; public class myaop {public void prever () {system.out.println ( "befor ~"); } public void After () {System.out.println ( "After ~"); }}Rasedao.java
패키지 ssh.dao.base; import javax.annotation.resource; import org.hibernate.ssessionfactory; import org.springframework.orm.hibernate4.support.hibernatedaosupport; public classe hibernatedaoSupport {@resource sedsessory setsectory (sessionfactorcorcorcor) {public classe org.springframework.orm.hibernate4.support.hibernatedaosupport; this.SetSessionFactory (SessionFactory); }}userdao.java
패키지 ssh.dao; import java.util.arraylist; import java.util.list; import org.springframework.orm.hibernate4.hibernateTemplate; import org.springframework.stereotype.repository; import ssh.dao.base.base.base.base.model.user; @repositority fullic.user; Raseao {public void add (사용자) {this.gethibernateTemplate (). 저장 (사용자); } @SuppressWarnings ( "선택 취소") 공개 목록 <user> QueryAllUser () {list <user> user = new ArrayList <User> (); HibernateTemplate HibernateTemplate = this.gethibernateTemplate (); HibernateTemplate.setCachequeries (true); user = (list <user>) hibernateTemplate.find ( "사용자에서"); HibernateTemplate.setCachequeries (false); 반환 사용자; }}user.java
패키지 ssh.model; import java.io.serializable; public class 사용자는 직렬화 가능 { / ** * / private static final long serialversionuid = -6190571611246371934L; 개인 긴 ID; 개인 문자열 계정; 개인 문자열 이름; 개인 문자열 주소; 공개 문자열 getAccount () {반환 계정; } public String getName () {return name; } public String getAddress () {return address; } public void setAccount (문자열 계정) {this.account = 계정; } public void setName (문자열 이름) {this.name = 이름; } public void setAddress (문자열 주소) {this.address = 주소; } / ** * @return id * / public long getId () {return id; } / ** * @param id 설정에 대한 ID * / public void setId (long id) {this.id = id; }}user.hbm.xml
<? xml version = "1.0"?> <!-~ hibernate, 관용적 인 Java ~ ~ Copyright (c) 2010, Red Hat Inc. 또는 @author tags 또는 Express Copyright Attribute ~ 저자가 적용한 진술에 대한 관계 적 지속성. 모든 타사 기부금은 Red Hat Inc.의 라이센스에 따라 배포됩니다. ~ ~이 저작권이있는 자료는 Free Software Foundation에서 게시 한 GNU ~ Less General Public License의 이용 약관에 따라 사용하고자하는 모든 사람이 이용할 수 있습니다. ~ ~이 프로그램은 유용 할 것이라는 희망으로 배포됩니다. 상업성에 대한 묵시적 보증조차도 ~ 또는 특정 목적에 대한 적합성. 자세한 내용은 GNU Less General Public License ~를 참조하십시오. ~ ~ 당신은이 배포와 함께 GNU Lesser General Public License의 사본을 받았어야합니다. 그렇지 않은 경우 : ~ Free Software Foundation, Inc. ~ 51 Franklin Street, 5 층 ~ Boston, MA 02110-1301 USA-> <! DocType Hibernate-Mapping Public "-// Hibernate/Hibernate 매핑 DTD 3.0 // en" " "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> hibernate-mapping package ="ssh.model "> <class name ="user "table ="user "> <cache usage ="read-write "/> <id name ="id "id"> <Generator/<Generator/<Generator/<Generator/> type = "java.lang.string"column = "ac
Userservice.java
패키지 ssh.service; import java.util.list; import javax.annotation.resource; import org.springframework.stereotyp.service; import ssh.dao.userdao; import ssh.model.user; @servicepublic classevice {@resource private userdao (newresourdao); 공개 목록 <user> QueryAllUser () {return userDao.queryAllUser (); } public void add (사용자) {userDao.add (사용자); }}index.jsp (jQuery 라이브러리 추가를 기억하십시오)
<%@ page language = "java"contmenttype = "text/html; charset = utf-8"pageencoding = "utf-8"%> <! doctype html public "-// w3c // dtml 4.01 Transitional // en" "http://www.w3.org/tr/tr/tr/html4/loose.dtd"> html> html> http-quiv ="content-type "content ="text/html; charset = utf-8 "> <title> 제목 </title> <style> .mt20 {margin-top. 20px;} </style> </head> <bod> <div style = "text-align : center;"> <div> <label> 계정 : </label> <입력 id = "ac "텍스트"/> </div> <div> <버튼 id = "Adduser"> 추가 </button> </div> <h3> 사용자 목록 : </h3> <ul id = "userList"> </ul> <Script Type = "Text/javaScript"src = "js/jquery-1.11.1.1.min.js"> </script> </script> </script> $ .ajax ({url : 'queryalluser.action', type : 'post', datatype : 'json', success : function (data) {try {for (var i = 0; i <data.length; i ++) {$ ( "#userList"). style = 'color : red'> id = "+data [i] .id+"</span>, ac }} catch (e) {}; }, error : function (e) {alert ( "sys error"); }}); $ ( "#addUser"). on ( "click", function () {var acc 함수 (데이터) {$ ( "#userlist"). }); }); </script> </body> </html>7. 검증 결과
처음으로 돌아가서 관련 기술에 익숙해지기 시작하고 결과를 확인하십시오.
1. 전통적인 SSH 개발 환경을 구축하고 성공적으로 실행하십시오 (삽입, 쿼리).
다음 그림 : 쿼리 및 추가 사용자 추가;
2. C3P0 연결 풀의 구성을 이해하십시오
데이터베이스 연결은 값 비싼 리소스이며 개방 및 폐쇄는 성능을 소비합니다. 따라서 연결 풀을 사용하여 관리 할 수 있으며, 몇 가지 연결을 초기화하고 반복적으로 닫는 것이 아니라 스레드 풀과 약간 유사합니다.
구성은 다음과 같습니다. 실제 프로젝트 상황에 따라 최소 및 최대 연결 수를 합리적으로 구성하려면 각 매개 변수의 상세한 의미에 대해서는 링크를 참조하십시오.
또한 연결 번호 구성을 확인하는 것은 매우 간단합니다. 직접 확인하기 위해 프로그램을 작성할 수 있습니다. 예를 들어, 최대 연결 수가 10 인 경우 프로그램을 작성하여 확인할 수 있습니다. 10 개의 연결을 열면 11 번째 연결은 대기 상태에 있으며 얻을 수 없습니다. 따라서 상황에 따라 합리적으로 연결 수를 구성해야합니다. 그렇지 않으면 응용 프로그램 성능에 영향을 줄 수 있습니다.
<!-지원 데이터 소스-> <bean name = "dataSource"dastaSource "dasve-method ="close "> <property name ="driver class "value ="com.mysql.jdbc.driver " /> <property name ="jdbcurl "value ="jdbc : mysql : // localhost : 3306 /demo " value = "root"/> <property name = "acquireIncrement"value = "1"> </property> <property name = "initialpoolsize"value = "80"> </property> <property name = "maxIdletime"value = "60"> </property> <속성 이름 = "maxpoolsize"value = "80"> </property> <value ""minpoolsize " 이름 = "acquireretrickDelay"value = "1000"> </property> <속성 이름 = "acquireretricatempts"value = "60"> </property> <속성 이름 = "breakfteracquirefailure"value = "false"> </propert> <! <! 명령 : show processlist) -> </bean>
3. 최대 절전 모드의 보조 캐시를 이해하고 확인하십시오
Hibernate의 첫 번째 수준 캐시는 기본적으로 활성화 된 세션 전체 캐시를 나타냅니다. 두 번째 레벨 캐시는 SessionFactory 범위 캐시입니다. SessionFactory를 구성 할 때는 두 번째 레벨 캐시를 Ehcache로 구성했습니다. 다음으로 효과를 확인하고 사용자 작업을 쿼리합니다. 첫 번째 쿼리가 데이터베이스를 작동하고 SQL 문을 인쇄하고 페이지를 새로 고침 한 후 쿼리가 성공하고 SQL 문이 인쇄되지 않았 음을 발견했습니다. 아래 그림과 같이 보조 캐시 작업이 정상임을 알 수 있습니다.
4. 스프링 물건의 구성을 이해하고 확인하십시오
소위 트랜잭션 제어 원칙은 동일하며, 이는 원자력, 일관성, 격리 및 지속성을 보장하는 것입니다. JDBC를 프로그래밍 할 때 자체적으로 제어됩니다. 자동으로 제출되지 않도록 AutoCommit = false를 설정 한 다음 특정 데이터베이스 작업을 작성하십시오. 예외가 발생하면 롤백, 그렇지 않으면 커밋하십시오. 실제로, 사물에 대한 스프링의 제어 원리는 비슷하며 서비스 계층에서 다른 방법을 제어하는 것과 같이 더 편리한 포장, 구성 등이 추가됩니다.
확인은 매우 간단합니다. 서비스 수준의 메소드에 두 개의 삽입 작업을 작성하고 (메소드 이름은 스프링 구성 파일에 구성된 규칙을 준수해야 함) 중간에 예외를 던지고 실행합니다. 첫 번째 사용자가 성공적으로 삽입된다는 것을 알게되면 트랜잭션 제어가 유효하지 않다는 것을 의미합니다. 그렇지 않으면 괜찮습니다.
5. Spring 's IOC (종속성 주입)를 이해하고 STRUTS2의 액션 객체 (BEAN)를 스프링 관리, 사용자 정의 Bean 등으로 넘겨주고 확인하십시오.
ApplicationContext.xml 파일을 구성하는 프로세스에서 신중하게 관찰되면 주요 작업은 Bean 관련 정보를 구성하는 것입니다. 이 콩은 미리 만들어 지지만 실제로 소위 콩은 물체입니다.
스프링 컨테이너에 물체를 생성하는 목적은 분리하는 것입니다.
또한 Struts를 사용할 때 스프링은 기본적으로 싱글 톤 인 Bean으로 동작을 등록합니다. 접근 중에 새로운 조치가 발행 될 때마다 동시에 접근 할 때 위험이 있습니다.
그러나 SCOPE = "프로토 타입"을 통해 작업을 여러 경우로 구성 할 수 있습니다. 추신 : struts2의 동작은 기본적으로 다중 사례입니다.
참고 : ApplicationContext.xml로 구성된 Bean은 프로그램 실행 중에 직접 사용자 정의 주석으로 구성된 Bean을 얻을 수 있습니다. 이것은 쉽게 확인하고 작은 프로그램을 작성하십시오.
6. Spring AOP (섹션 지향 프로그래밍)를 이해하고 결과를 확인하기 위해 사용자 정의 섹션 기능을 작성하십시오.
이 아이디어는 필터, 인터셉터, 트랜잭션 제어 등과 같은 이러한 형태의 단면 프로그래밍의 여러 곳에서 사용됩니다.
원칙은 Java Reflection and Dynamic Proxy이며, 이는 실행 전후의 방법을 제어하고 실행하려는 코드를 추가합니다.
섹션이 작은 예제에 추가되며, 방법 전후에 문자열이 실행되기 전후 인쇄됩니다. 아래 그림과 같이 정상적으로 작동합니다. 코드의 이전 부분을 참조하십시오.
<!-사용자 정의 AOP 처리 테스트-> <bean id = "aoptest"> </bean> <bean id = "myaop"> </bean> <aop : config proxy-target class = "true"> <aop : "myaop"> <aop : pointcut id = "pcmethodtest"expression = ") <aop : pointcut-Ref = "pcmethodtest"method = "prever"/> <aop : pointcut-ref = "pcmethodtest"method = "apject"/> </aop : 측면> </aop : config>
@Author 바람과 같은 코더
위는이 기사의 모든 내용입니다. 모든 사람의 학습에 도움이되기를 바랍니다. 모든 사람이 wulin.com을 더 지원하기를 바랍니다.