eclipse配置S2SH搭建过程及错误解决
2012-12-01 14:21
323 查看
PS:半年没摸S2SH框架 不知道怎么配了。以前都是myeclipse自己来配置。
so准备拿eclipse自己配置下练练,问龙哥要了以前的代码作参考。
mark一下 老了记性不行~!
简单数据验证、插入操作DEMO下载地址
(注意环境区别)
需要资源:
spring-framework-3.1.3.RELEASE 传送门
struts-2.3.7-all 传送门
hibernate-distribution-3.6.0.Beta3-dist 传送门
eclipse 传送门
jdk7.0 传送门
tomcat
7 传送门
一、目录结构
二、所有的jar包 如下图
三、遇到问题
其中很明显下载框架包里面没有的jar包
commons-pool-1.6.jar apache的通用池jar包 struts2.3.7里面没有提供
传送门
slf4j-nop-1.6.1.jar hibernate没有提供
传送门
貌似可以了,但是各种红色....... 心里拔凉啊
真心eclipse麻烦 ,但是它没myeclipse占资源
错误1
使用Spring集成hibernate3,在添加声明式事务管理后
java.lang.NoClassDefFoundError: org/aspectj/weaver/BCException
错误原因:缺少aspectjweaver-1.5.3.jar 传送门
错误2
出现了java.lang.NoClassDefFoundError:的错误
org.springframework.beans.factory.BeanDefinitionStoreException:
Caused by: java.lang.NoClassDefFoundError: org/aopalliance/intercept/MethodInterceptor
Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from class path
resource [SpringConfig_Jdbc.xml]; nested exception is java.lang.NoClassDefFoundError: org/aopalliance/intercept/MethodInterceptor(省略)...Caused by: java.lang.NoClassDefFoundError: org/aopalliance/intercept/MethodInterceptor
错误原因:缺少 aopalliance.jar 传送门
错误3
java.lang.NoClassDefFoundError: edu/emory/mathcs/backport/java/util/concurrent/BlockingQueue
上面情况还会导致在启动tomcat时出现以下错误:
org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'sessionFactory' defined in class path resource [Beans.xml]: Invocation of init method failed; nested exception is net.sf.ehcache.CacheException: Error configuring from file:/D:/Eclipse/Work/workspace/.metadata/.me_tcat/webapps/SSH/WEB-INF/classes/ehcache.xml.
Initial cause was Error configuring from input stream. Initial cause was Invalid byte 1 of 1-byte UTF-8 sequence.
错误原因:缺少backport-util-concurrent.jar 传送门
问题4
ok 最后跑起来了,但是出现下面的情况
***********************************************************************
* WARNING!!! *
* *
* >>> FilterDispatcher <<< is deprecated! Please use the new filters! *
* *
* This
can be a source of unpredictable problems! *
* *
* Please
refer to the docs for more details! *
* http://struts.apache.org/2.x/docs/webxml.html ; *
* *
***********************************************************************
原因:
-------------- end 配置完成-------------------------
附:
web.xml
struts.xml
hibernate.cfg.xml
applicationContext-comms.xml
applicationContext-beans.xml
applicationContext-actions.xml
文件:web.xml
文件:struts.xml
文件:hibernate.cfg.xml
文件:applicationContext-comms.xml
文件:applicationContext-beans.xml
文件:applicationContext-actions.xml
注意 实现接口的方法要继承 HibernateDaoSupport哦,要不....你懂得
后续有问题再补.....
so准备拿eclipse自己配置下练练,问龙哥要了以前的代码作参考。
mark一下 老了记性不行~!
简单数据验证、插入操作DEMO下载地址
(注意环境区别)
需要资源:
spring-framework-3.1.3.RELEASE 传送门
struts-2.3.7-all 传送门
hibernate-distribution-3.6.0.Beta3-dist 传送门
eclipse 传送门
jdk7.0 传送门
tomcat
7 传送门
一、目录结构
二、所有的jar包 如下图
三、遇到问题
其中很明显下载框架包里面没有的jar包
commons-pool-1.6.jar apache的通用池jar包 struts2.3.7里面没有提供
传送门
slf4j-nop-1.6.1.jar hibernate没有提供
传送门
貌似可以了,但是各种红色....... 心里拔凉啊
真心eclipse麻烦 ,但是它没myeclipse占资源
错误1
使用Spring集成hibernate3,在添加声明式事务管理后
java.lang.NoClassDefFoundError: org/aspectj/weaver/BCException
错误原因:缺少aspectjweaver-1.5.3.jar 传送门
错误2
出现了java.lang.NoClassDefFoundError:的错误
org.springframework.beans.factory.BeanDefinitionStoreException:
Caused by: java.lang.NoClassDefFoundError: org/aopalliance/intercept/MethodInterceptor
Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from class path
resource [SpringConfig_Jdbc.xml]; nested exception is java.lang.NoClassDefFoundError: org/aopalliance/intercept/MethodInterceptor(省略)...Caused by: java.lang.NoClassDefFoundError: org/aopalliance/intercept/MethodInterceptor
错误原因:缺少 aopalliance.jar 传送门
错误3
java.lang.NoClassDefFoundError: edu/emory/mathcs/backport/java/util/concurrent/BlockingQueue
上面情况还会导致在启动tomcat时出现以下错误:
org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'sessionFactory' defined in class path resource [Beans.xml]: Invocation of init method failed; nested exception is net.sf.ehcache.CacheException: Error configuring from file:/D:/Eclipse/Work/workspace/.metadata/.me_tcat/webapps/SSH/WEB-INF/classes/ehcache.xml.
Initial cause was Error configuring from input stream. Initial cause was Invalid byte 1 of 1-byte UTF-8 sequence.
错误原因:缺少backport-util-concurrent.jar 传送门
问题4
ok 最后跑起来了,但是出现下面的情况
***********************************************************************
* WARNING!!! *
* *
* >>> FilterDispatcher <<< is deprecated! Please use the new filters! *
* *
* This
can be a source of unpredictable problems! *
* *
* Please
refer to the docs for more details! *
* http://struts.apache.org/2.x/docs/webxml.html ; *
* *
***********************************************************************
原因:
自Struts 2.1.3后,FilterDispatcher已被标注为过时
在Struts2的官方网上会看到:To split up the the dispatcher phases, FilterDispatcher is deprecated since Struts 2.1.3.
即从Struts 2.1.3起已被标注为过时的,该用StrutsPrepareAndExecuteFilter
<filter> <filter-name>struts2</filter-name> <filter-class> org.apache.struts2.dispatcher.FilterDispatcher <!-- 这一句修改为最新的 --> </filter-class> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>改为:
<filter> <filter-name>struts2</filter-name> <filter-class> org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter </filter-class> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
-------------- end 配置完成-------------------------
附:
web.xml
struts.xml
hibernate.cfg.xml
applicationContext-comms.xml
applicationContext-beans.xml
applicationContext-actions.xml
文件:web.xml
<?xml version="1.0" encoding="UTF-8"?> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:applicationContext-*.xml</param-value> </context-param> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> </web-app>
文件:struts.xml
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd"> <struts> <!--常用常量配置--> <!--打开开发模式--> <constant name="struts.devMode" value="false"></constant> <!-- 指定每次请求到达,重新加载资源文件 --> <constant name="struts.i18n.reload" value="true" /> <!-- 指定每次配置文件更改后,自动重新加载 --> <constant name="struts.configuration.xml.reload" value="true" /> <!-- 默认的视图主题 --> <constant name="struts.ui.theme" value="simple" /> <!--最大文件上传大小--> <constant name="struts.multipart.maxSize" value="10485760"></constant> <include file="struts-login.xml"/> </struts>
文件:hibernate.cfg.xml
<?xml version='1.0' encoding='utf-8'?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory> <!-- hibernate dialect --> <property name="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</property> <property name="hibernate.connection.driver_class">com.microsoft.sqlserver.jdbc.SQLServerDriver</property> <property name="hibernate.connection.url">jdbc:sqlserver://localhost:1433;DatabaseName=Test</property> <property name="hibernate.connection.username">sa</property> <property name="hibernate.connection.password">f123456!</property> <!-- JDBC connection properties (end) --> <!-- 显示sql语句 --> <property name="show_sql">true</property> <!-- 自动更新表结构 --> <!--<property name="hbm2ddl.auto">update</property>--> <!-- %%%%%%%%%%%%%%%%%%%%%%%%%%使用c3p0连接池%%%%%%%%%%%%%%%%%%%%%%%%%% --> <!-- 最大连接数 --> <property name="hibernate.c3p0.max_size">25</property> <!-- 最小连接数 --> <property name="hibernate.c3p0.min_size">5</property> <!-- 获得连接的超时时间,如果超过这个时间,会抛出异常,单位毫秒 --> <property name="hibernate.c3p0.timeout">1800</property> <!-- 最大的PreparedStatement的数量 --> <property name="hibernate.c3p0.max_statements">100</property> <!-- 每隔120秒检查连接池里的空闲连接 ,单位是秒--> <property name="hibernate.c3p0.idle_test_period">120</property> <!-- 当连接池里面的连接用完的时候,C3P0一下获取的新的连接数 --> <property name="hibernate.c3p0.acquire_increment">2</property> <!-- 每次都验证连接是否可用 --> <property name="hibernate.c3p0.validate">true</property> <!-- %%%%%%%%%%%%%%%%%%%%%%%%%%使用EHCache二级缓存%%%%%%%%%%%%%%%%%%%%%%%%%% --> <property name="cache.use_second_level_cache">true</property> <property name="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</property> <property name="hibernate.cache.use_query_cache">true</property> <!-- 声明映射文件 --> <!-- <property name="myeclipse.connection.profile">book</property> --> <mapping resource="com/adminSystem/entity/UserInfo.hbm.xml" /> </session-factory> </hibernate-configuration>
文件:applicationContext-comms.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:p="http://www.springframework.org/schema/p" 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-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd"> <context:annotation-config/> <!--配置Hibernate的SessionFactory--> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="configLocation" value="classpath:hibernate.cfg.xml"></property> </bean> <bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate"> <property name="sessionFactory" ref="sessionFactory"></property> </bean> <!--配置事务管理器--> <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory"></property> </bean> <!--配置事务的传播特性--> <tx:advice id="txAdvice" transaction-manager="transactionManager"> <tx:attributes> <tx:method name="save*" propagation="REQUIRED"/> <tx:method name="add*" propagation="REQUIRED"/> <tx:method name="update*" propagation="REQUIRED"/> <tx:method name="delete*" propagation="REQUIRED"/> <tx:method name="init*" propagation="REQUIRED"/> <tx:method name="*" propagation="REQUIRED" read-only="true"/> </tx:attributes> </tx:advice> <!--哪些类的哪些方法要使用事务--> <aop:config> <aop:pointcut expression="execution(* com.adminSystem.service.impl.*.*(..))" id="allServiceMethod"/> <aop:advisor advice-ref="txAdvice" pointcut-ref="allServiceMethod"/> </aop:config> </beans>
文件:applicationContext-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:p="http://www.springframework.org/schema/p" 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-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd"> <context:annotation-config /> <!-- <bean class="org.springframework.context.annotation.CommonAnnotationBeanPostProcessor" /> --> <!--注入数据访问层对象--> <bean id="userDAO" class="com.adminSystem.dao.impl.UserDAOImpl"> <property name="sessionFactory" ref="sessionFactory"></property> </bean> <!--注入业务逻辑组件--> <bean id="userService" class="com.adminSystem.service.impl.UserServiceImpl"> </bean> </beans>
文件:applicationContext-actions.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:p="http://www.springframework.org/schema/p" 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-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd"> <!--登录管理 --> <bean id="loginAction" class="com.adminSystem.web.LoginAction"></bean> <bean id="userAction" class="com.adminSystem.web.UserAction"></bean> </beans>
注意 实现接口的方法要继承 HibernateDaoSupport哦,要不....你懂得
后续有问题再补.....
相关文章推荐
- MonkeyRunner于Windows在下面Eclipse开发环境的搭建步骤(并解决在线Jython配置错误的问题)
- asp.net配置IIS过程错误解决
- eclipse开发php全过程的搭建带debug的配置
- 解决“在eclipse中配置Tomcat时,出现Cannot create a server using the selected type的错误”的问题
- react-native学习(RN)--之Window环境下搭建环境配置,以及初始化建立react-native项目,(真机和模拟器运行的相关错误解决办法,android打包报错)
- NDK在eclipse下的配置及错误解决
- Hadoop-2.8.0集群搭建、hadoop源码编译和安装、host配置、ssh免密登录、hadoop配置文件中的参数配置参数总结、hadoop集群测试,安装过程中的常见错误
- Arcgis Server 配置过程常见错误解决
- smb服务器配置过程遇到错误及解决
- Android - MonkeyRunner配置或安装过程中出现错误解决办法
- eclipse错误: 找不到或无法加载主类解决过程
- eclipse中导入tomcat源码的配置流程(附版本号和错误解决)
- 成功安装VPSMate解决各种错误和用VPSMate搭建网站全过程
- MySQL搭建过程中的“/tmp/mysql.sock"错误解决
- Eclipse配置Lifery SDK步骤与错误解决。
- 学习openfrie之路--将openfire源码导入eclipse第二次开发的导入错误解决和配置设置
- ldap安装配置过程中遇到的错误,以及解决方法
- Qt 4.8.2 VS2008 集成环境搭建过程中编译错误的解决办法
- MonkeyRunner在Windows下的Eclipse开发环境搭建步骤(兼解决网上Jython配置出错的问题)
- mysql5.7.13 sql_mode(1055错误)配置错误解决过程记录