Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
struts2-不带struts2 spring插件的spring集成_Spring_Struts2_Dynamic Proxy_Struts2 Spring Plugin - Fatal编程技术网

struts2-不带struts2 spring插件的spring集成

struts2-不带struts2 spring插件的spring集成,spring,struts2,dynamic-proxy,struts2-spring-plugin,Spring,Struts2,Dynamic Proxy,Struts2 Spring Plugin,我想知道SpringBeanPersonService对象是如何在不使用struts-spring插件的情况下分配给setPersonService方法的,当我尝试跟踪操作类methodsetPersonService时,我得到了JdkDynamicAopProxy关键字。但我对JdkDynamicAopProxy一无所知 撑杆动作 public class AllPersonsFinder extends ActionSupport { private List<Per

我想知道SpringBeanPersonService对象是如何在不使用struts-spring插件的情况下分配给setPersonService方法的,当我尝试跟踪操作类methodsetPersonService时,我得到了JdkDynamicAopProxy关键字。但我对JdkDynamicAopProxy一无所知

撑杆动作

 public class AllPersonsFinder extends ActionSupport {
        private List<Person> persons;
        private transient PersonService personService;

        @Override
        public String execute() throws Exception {
            persons = personService.findAllEmployees();
            return SUCCESS;
        }

        public List<Person> getPersons() {
            return persons;
        }

        public void setPersons(List<Person> persons) {
            this.persons = persons;
        }

        public PersonService getPersonService() {
            return personService;
        }

        public void setPersonService(PersonService personService) {
            this.personService = personService;
        }
    }
Struts配置

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
    "http://struts.apache.org/dtds/struts-2.0.dtd">

<struts>

    <constant name="struts.devMode" value="true" />

    <package name="springjpaexample" extends="struts-default">

        <interceptors>
            <interceptor-stack name="appDefaultStack">
                <interceptor-ref name="defaultStack">
                    <param name="exception.logEnabled">true</param>
                    <param name="exception.logLevel">ERROR</param>
                </interceptor-ref>
            </interceptor-stack>
        </interceptors>

        <default-interceptor-ref name="appDefaultStack" />

        <global-results>
            <result name="error">/error.jsp</result>
        </global-results>


        <global-exception-mappings>
            <exception-mapping exception="java.lang.Exception"
                result="error" />
        </global-exception-mappings>

        <action name="personFinder"
            class="edu.ku.it.si.springjpaexample.action.PersonFinder" method="execute">
            <result name="success">/personinfo.jsp</result>
        </action>

        <action name="allPersonsFinder"
            class="edu.ku.it.si.springjpaexample.action.AllPersonsFinder" method="execute">

            <result name="success">/personsinfo.jsp</result>

        </action>

        <action name="*PersonUpdate"
            class="edu.ku.it.si.springjpaexample.action.PersonUpdater" method="{1}">

            <result name="input">/inputpersonupdate.jsp</result>
            <result name="success">/personupdated.jsp</result>

        </action>

        <action name="personDelete"
            class="edu.ku.it.si.springjpaexample.action.PersonDeleter" method="execute">

            <result name="success">/persondeleted.jsp</result>

        </action>

        <action name="*PersonSave" class="edu.ku.it.si.springjpaexample.action.PersonSaver"
            method="{1}">

            <result name="input">/inputpersonsave.jsp</result>
            <result name="success">/personsaved.jsp</result>

        </action>

    </package>

</struts>
春豆

@Service("personService")
public class PersonServiceImpl implements PersonService {

     @Autowired
     private PersonDao personDao;

    @Override
    public Person findbyEmplid(Long emplid) {
        return personDao.findbyEmplid(emplid);
    }

    public PersonDao getPersonDao() {
        return personDao;
    }

    public void setPersonDao(PersonDao personDao) {
        this.personDao = personDao;
    }

    @Override
    public List<Person> findAllEmployees() {
        return personDao.findAllEmployees() ;
    }

    @Override
    @Transactional
    public void update(Person person) {
        personDao.update(person);
    }

    @Override
    @Transactional
    public void delete(Person person) {
        personDao.delete(person);
    }

    @Override
    @Transactional
    public void save(Person person) {
        personDao.save(person); //Person object's emplid instance field will now have a value
    }
}
弹簧配置

<?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.w3.org/2001/XMLSchema-instance"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xmlns:jdbc="http://www.springframework.org/schema/jdbc"
       xsi:schemaLocation="
            http://www.springframework.org/schema/beans
            http://www.springframework.org/schema/beans/spring-beans.xsd
            http://www.springframework.org/schema/aop
            http://www.springframework.org/schema/aop/spring-aop.xsd
            http://www.springframework.org/schema/tx
            http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
            http://www.springframework.org/schema/jdbc
            http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd
            http://www.springframework.org/schema/context
            http://www.springframework.org/schema/context/spring-context-3.0.xsd">

    <!-- scans the classpath for annotated components (including @Repostory 
    and @Service  that will be auto-registered as Spring beans  -->          
    <context:component-scan base-package="edu.ku.it.si.springjpaexample" />

    <!-- methods or classes needing to run in a complete transaction will
    be annotated with Transactional -->
    <tx:annotation-driven />

    <!-- Creates a data source that can provide a connection to in-memory embedded database populated 
    with test data
    see: http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/ch12s08.html   -->
   <jdbc:embedded-database id="dataSource">
        <jdbc:script location="classpath:schema.sql"/>
        <jdbc:script location="classpath:test-data.sql"/>
    </jdbc:embedded-database>


    <!-- This will ensure that hibernate or jpa exceptions are automatically translated into
         Spring's generic DataAccessException hierarchy for those classes annotated with Repository
         For example see PersonDaoJpa-->
    <bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor"/>

    <!-- JPA Entity Manager Factory -->
    <bean id="entityManagerFactory" 
          class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
          p:dataSource-ref="dataSource"
          p:persistenceXmlLocation="META-INF/persistence.xml" 
          p:persistenceUnitName="springJpaPersistenceUnit" />          


    <!-- bean post-processor for JPA annotations -->
    <bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />


    <!-- Transaction Config -->
    <bean id="transactionManager"
          class="org.springframework.orm.jpa.JpaTransactionManager"
          p:entityManagerFactory-ref="entityManagerFactory"/>

    <!-- use declarative transaction management  -->
    <tx:annotation-driven  transaction-manager="transactionManager"/>

 </beans>

你的问题是什么是JDK动态AOP代理?我的问题是struts2 action对象在没有spring插件的情况下是如何获得spring服务的。这是spring处理此问题的一种方式,以下是spring源代码中的详细信息,而不必查看spring配置,就不可能知道哪些类。如果没有Spring插件,S2本身将完全从运行时的Spring处理中删除,您需要提供更多关于S2和Spring配置的信息,以及您正在部署的库。