Unable to instantiate Action, categoryAction, defined for 'category_queryJoinAccount' in namespace
来源:互联网 发布:上海离婚率数据 编辑:程序博客网 时间:2024/05/17 07:35
在开发过程中,突然遇到此问题,纠结了一下午,也没有结果,在网上搜的答案,基本上都没有出现,造成此问题的原因有很多,我遇到的原因只是其中之一,那么是什么错误造成此类问题,我的解决方案是什么呢,接下来奉上相关代码以及问题的解决:
<struts>
<constant name="struts.enable.DynamicMethodInvocation" value="true"></constant>
<package name="myshop" extends="json-default" namespace="/">
<global-results>
<result name="aindex">/WEB-INF/main/aindex.jsp</result>
</global-results>
<global-allowed-methods>regex:.*</global-allowed-methods>
<action name="go_*_*" class="goAction">
<result name="go">/WEB-INF/{1}/{2}.jsp</result>
</action>
<action name="category_*" class="categoryAction" method="{1}">
<result name="jsonMap" type="json">
<param name="root">pageMap</param>
</result>
<result name="stream" type="stream">
<param name="inputName">inputStream</param>
</result>
</action>
</package>
</struts>
------------------------------------------------------------------
<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-4.3.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd">
<!-- 扫描注解 -->
<context:component-scan base-package="it.fly"/>
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="driverClass" value="com.mysql.jdbc.Driver"></property>
<property name="jdbcUrl" value="jdbc:mysql://localhost:3306/shop"/>
<property name="user" value="root"></property>
<property name="password" value="root"></property>
</bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"></property>
<property name="configLocation" value="classpath:hibernate.cfg.xml"></property>
</bean>
<bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<tx:advice id="advice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="save*" propagation="REQUIRED"/>
<tx:method name="update*" propagation="REQUIRED"/>
<tx:method name="delete*" propagation="REQUIRED"/>
<tx:method name="*" propagation="SUPPORTS"/>
</tx:attributes>
</tx:advice>
<aop:config>
<aop:pointcut id="pointcut" expression="execution(* it.fly.service.impl.*.*(..))"/>
<aop:advisor advice-ref="advice" pointcut-ref="pointcut"/>
</aop:config>
<bean id="goAction" class="it.fly.action.GoAction" scope="prototype">
</bean>
<bean id="categoryAction" class="it.fly.action.CategoryAction" scope="prototype"></bean>
<bean id="accountAction" class="it.fly.action.AccountAction" scope="prototype"></bean>
</beans>
-------------------------------------------------------------------------
package it.fly.service.impl;
import org.springframework.stereotype.Service;
import it.fly.domain.Account;
import it.fly.service.AccountService;
/**
* @author
* @param <T>
*
*/
public class AccountServiceImpl extends BaseServiceImpl<Account> implements AccountService{
}
---------------------------------------------------
1.大家应该有人发现serviceimpl代码有点问题,那么就是没有加service注解,
2.由于没有加注解,没有被spring扫描到,因此bean没有被spring的bean管理器加载出来。因为使用的是自动注入,所以action里边在注入的时候是找不到此service的。
3.再加上@service注解后,问题就解决了。
---------------------------------------------------
说明:此为本人第一篇博客,语言上的组织可能有问题,望大家见谅,会在以后的博客中慢慢改进,共同成长,共同进步
<struts>
<constant name="struts.enable.DynamicMethodInvocation" value="true"></constant>
<package name="myshop" extends="json-default" namespace="/">
<global-results>
<result name="aindex">/WEB-INF/main/aindex.jsp</result>
</global-results>
<global-allowed-methods>regex:.*</global-allowed-methods>
<action name="go_*_*" class="goAction">
<result name="go">/WEB-INF/{1}/{2}.jsp</result>
</action>
<action name="category_*" class="categoryAction" method="{1}">
<result name="jsonMap" type="json">
<param name="root">pageMap</param>
</result>
<result name="stream" type="stream">
<param name="inputName">inputStream</param>
</result>
</action>
</package>
</struts>
------------------------------------------------------------------
<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-4.3.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd">
<!-- 扫描注解 -->
<context:component-scan base-package="it.fly"/>
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="driverClass" value="com.mysql.jdbc.Driver"></property>
<property name="jdbcUrl" value="jdbc:mysql://localhost:3306/shop"/>
<property name="user" value="root"></property>
<property name="password" value="root"></property>
</bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"></property>
<property name="configLocation" value="classpath:hibernate.cfg.xml"></property>
</bean>
<bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<tx:advice id="advice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="save*" propagation="REQUIRED"/>
<tx:method name="update*" propagation="REQUIRED"/>
<tx:method name="delete*" propagation="REQUIRED"/>
<tx:method name="*" propagation="SUPPORTS"/>
</tx:attributes>
</tx:advice>
<aop:config>
<aop:pointcut id="pointcut" expression="execution(* it.fly.service.impl.*.*(..))"/>
<aop:advisor advice-ref="advice" pointcut-ref="pointcut"/>
</aop:config>
<bean id="goAction" class="it.fly.action.GoAction" scope="prototype">
</bean>
<bean id="categoryAction" class="it.fly.action.CategoryAction" scope="prototype"></bean>
<bean id="accountAction" class="it.fly.action.AccountAction" scope="prototype"></bean>
</beans>
-------------------------------------------------------------------------
package it.fly.service.impl;
import org.springframework.stereotype.Service;
import it.fly.domain.Account;
import it.fly.service.AccountService;
/**
* @author
* @param <T>
*
*/
public class AccountServiceImpl extends BaseServiceImpl<Account> implements AccountService{
}
---------------------------------------------------
1.大家应该有人发现serviceimpl代码有点问题,那么就是没有加service注解,
2.由于没有加注解,没有被spring扫描到,因此bean没有被spring的bean管理器加载出来。因为使用的是自动注入,所以action里边在注入的时候是找不到此service的。
3.再加上@service注解后,问题就解决了。
---------------------------------------------------
说明:此为本人第一篇博客,语言上的组织可能有问题,望大家见谅,会在以后的博客中慢慢改进,共同成长,共同进步
0 0
- Unable to instantiate Action, categoryAction, defined for 'category_queryJoinAccount' in namespace
- Unable to instantiate Action,,,,,,,,,defined for ',,,' in namespace '/,,,'null
- Unable to instantiate Action,,,,,,,,,defined for ',,,' in namespace '/,,,'null
- Unable to instantiate Action, goodsTypeAction, defined for 'goodsType_findAdvanced' in namespace '/
- Unable to instantiate Action, defined for t' in namespace '/'XXXAction
- Unable to instantiate Action, loginAction, defined for 'login' in namespace
- Unable to instantiate Action, defined for in namespace '/'
- 八、Unable to instantiate Action, xxx.action.DeleteAction, defined for 'delete' in namespace
- Unable to instantiate Action,xxx-action, defined for 'xxx' in namespace '/xxx/xxxx/xxxxx'Error crea
- 整合SSH后出现Unable to instantiate Action, student, defined for 'add_StudentAction' in namespace '/'stude
- 出现"Unable to instantiate Action,xxxxx, defined for 'login' in namespace '/' xxxxx 解决办法
- Unable to instantiate Action, xxxAction, defined for 'xxx' in namespace '/'xxxAction解决方案
- 异常4: Unable to instantiate Action, AddZhangMuAction, defined for 'AddZhangAction' in namespace ...
- Unable to instantiate Action, MenuAction, defined for 'QueryMenuAll' in namespace '/'MenuAction
- 异常处理:Unable to instantiate Action, checkLoginAction, defined for 'checkUser' in namespace '/'Error
- Unable to instantiate Action, departmentAction, defined for 'department_list' in namespace '/'depart
- Unable to instantiate Action, xxxAction, defined for ‘xxx’ in namespace ‘/’xxxAction
- Unable to instantiate Action, XXXAction, defined for 'xx' in namespace 'xx'报错解决
- Oracle--加快建立索引速度
- rk3288 i2c 写双字节地址
- POI操作Excel项目实例demo
- Apache Hive
- SELinux app权限配置
- Unable to instantiate Action, categoryAction, defined for 'category_queryJoinAccount' in namespace
- android studio 的一个问题Error:Gradle version 2.2 is required. Current version is 2.14.1. If using the gr
- typeof、toString()总结
- android activity启动优化方法
- 并查集的模版
- require.js入门教程
- JDK动态代理实现原理
- Bootstrap学习-排版
- 深入了解Arras.sort()与Collections.sort()的区别