1. 在eclipse运行ssh项目出现以下错误信息:
HTTP Status 500 - Unable to instantiate Action.......................
错误信息太多就不写了。
2. 出现以上问题可能是:
在applicationContext.xml配置文件中,把用Repository, Service, Controller注解的bean加到spring容器中, 填写的基包名与项目的基包名不一致。
1.
2.
此项目本人采用的是struts2+hibernate4+spring4写的
ApplicationContext.xml
xmlversion="1.0"encoding="UTF-8"?>
<beansxmlns="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"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/txhttp://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/aophttp://www.springframework.org/schema/aop/spring-aop-3.2.xsd">
<beanid="dataSource"
class="com.mchange.v2.c3p0.ComboPooledDataSource">
<propertyname="jdbcUrl"value="jdbc:mysql://localhost:3306/shopstore">property>
<propertyname="user"value="root">property>
<propertyname="password"value="root">property>
<propertyname="driverClass"value="com.mysql.jdbc.Driver">property>
<propertyname="minPoolSize"value="10"/>
<propertyname="maxPoolSize"value="100"/>
<propertyname="maxIdleTime"value="1800"/>
<propertyname="acquireIncrement"value="3"/>
<propertyname="maxStatements"value="1000"/>
<propertyname="initialPoolSize"value="10"/>
<propertyname="idleConnectionTestPeriod"value="60"/>
<propertyname="acquireRetryAttempts"value="30"/>
<propertyname="breakAfterAcquireFailure"value="true"/>
<propertyname="testConnectionOnCheckout"value="false"/>
bean>
<beanid="sessionFactory"
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<propertyname="dataSource">
<refbean="dataSource"/>
property>
<propertyname="hibernateProperties">
<props>
<propkey="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBDialectprop>
<propkey="hibernate.hbm2ddl.auto">updateprop>
<propkey="hibernate.current_session_context_class">
org.springframework.orm.hibernate4.SpringSessionContextprop>
<propkey="hibernate.show_sql">trueprop>
<propkey="hibernate.format_sql">trueprop>
props>
property>
<propertyname="mappingResources">
<list>
<value>base/bean/admin.hbm.xmlvalue>
list>
property>
bean>
<beanid="transactionManager"
class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<propertyname="sessionFactory"ref="sessionFactory"/>
bean>
<tx:adviceid="txAdvice"transaction-manager="transactionManager">
<tx:attributes>
<tx:methodname="select*"propagation="REQUIRED"/>
<tx:methodname="save*"propagation="REQUIRED"/>
<tx:methodname="delete*"propagation="REQUIRED"/>
<tx:methodname="update*"propagation="REQUIRED"/>
<tx:methodname="get*"read-only="true"propagation="REQUIRED"/>
<tx:methodname="*"read-only="true"/>
tx:attributes>
tx:advice>
<aop:configexpose-proxy="true">
<aop:pointcutid="pt"expression="execution(*base.service.*.*(..))"/>
<aop:advisoradvice-ref="txAdvice"pointcut-ref="pt"/>
aop:config>
beans>
Web.xml
xmlversion="1.0"encoding="UTF-8"?>
<web-appxmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaeehttp://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID"version="3.0">
<display-name>ShoppingStoredisplay-name>
<filter>
<filter-name>struts2filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilterfilter-class>
filter>
<filter-mapping>
<filter-name>struts2filter-name>
<url-pattern>/*url-pattern>
filter-mapping>
<context-param>
<param-name>contextConfigLocationparam-name>
<param-value>classpath:applicationContext.xmlparam-value>
context-param>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
listener-class>
listener>
web-app>
Struts.xml
xmlversion="1.0"encoding="UTF-8"?>
DOCTYPEstrutsPUBLIC
"-//ApacheSoftware Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>
<constantname="struts.multipart.maxSize"value="52428800">constant>
<constantname="struts.objectFactory"value="spring">constant>
<packagename="admin"extends="struts-default">
<actionname="login"class="adminaction"method="login">
<resultname="loginsuccess"type="redirectAction">
home
result>
<resultname="loginfail">/admin/index.jspresult>
action>
这是我遇到的错误,修改后可用,此方案仅供参考。