当前位置:编程学习 > JAVA >>

Myeclipse10.0 SSH整合开发

Myeclipse SSH整合开发 就是Add xxx capabilities那种
可能是jar包的原因,运行程序就是404
网上的ssh整合都是以前的了
额,好吧,我承认我是菜鸟,什么都不会
求手把手搭建一个ssh环境。
给出我全部的分了 SSH MyEclipse --------------------编程问答-------------------- 你可以不用MyEclipse的提供的方式添加SSH框架,这样你就只能用MyEclipse提供的SSH的版本,不能用最新的。最好是自己添加相关配置文件,再把jar包及依赖包添加的lib里,这样也可以使用相关框架。

我在MyEclipse10中搭建的SSH框架,给你参考下:

web.xml配置:
<?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" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<display-name></display-name>
<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>


applicationContext.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:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context"
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 />
<context:component-scan base-package="***.***.***" />

<!-- 读取config.properties配置文件 -->
<context:property-placeholder location="classpath:config.properties" />
<!-- 数据源 -->
<bean id="dataSource" class="com.jolbox.bonecp.BoneCPDataSource"
destroy-method="close">
<property name="driverClass" value="${driverClass}" />
<property name="jdbcUrl" value="${jdbcUrl}" />
<property name="username" value="${username}" />
<property name="password" value="${password}" />
<!--检查数据库连接池中空闲连接的间隔时间,单位是分,默认值:4,如果要取消则设置为0 -->
<property name="idleConnectionTestPeriodInMinutes" value="${idleConnectionTestPeriodInMinutes}" />
<!-- 连接池中未使用的链接最大存活时间,单位是分,默认值:1,如果要永远存活设置为0 -->
<property name="idleMaxAgeInMinutes" value="${idleMaxAgeInMinutes}" />
<!-- 设置每个分区含有connection最大个数 -->
<property name="maxConnectionsPerPartition" value="${maxConnectionsPerPartition}" />
<!-- 设置每个分区含有connection最小个数 -->
<property name="minConnectionsPerPartition" value="${minConnectionsPerPartition}" />
<!-- 分区数 ,默认值2,最小1,推荐3-4,视应用而定 -->
<property name="partitionCount" value="${partitionCount}" />
<!-- 设置分区中的connection增长数量 -->
<property name="acquireIncrement" value="${acquireIncrement}" />
<!-- 设置报告缓冲区大小 -->
<property name="statementsCacheSize" value="${statementsCacheSize}" />
<!-- 设置发布帮助线程数 -->
<property name="releaseHelperThreads" value="${releaseHelperThreads}" />
</bean>

<!-- Hibernate3配置,sessionFactory配置 -->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<!-- 配置SessionFactory所需的数据源,注入上面定义的dataSource -->
<property name="dataSource">
<ref bean="dataSource" />
</property>
<!-- 定义hibernate的SessionFactory的属性 -->
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.MySQLDialect
</prop>
<prop key="hibernate.show_sql">false</prop>
</props>
</property>
<!-- mappingResources属性用来列出全部映射文件 -->
<property name="mappingResources">
<list>
<!-- 配置所有PO映射文件 -->
<value>***/****/****.hbm.xml</value>
</list>
</property>
</bean>

<!-- 配置事务 -->
<bean id="txManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<!-- 采用注解方式配置事务 -->
<tx:annotation-driven transaction-manager="txManager" />

</beans>

其中的“*”号表示包名。

SSH框架集成在一起的配置文件主要是这两个文件,Hibernate的hbm.xml文件按照Hibernate的要求去写就可以了。再加入相关jar包及依赖包就可以了。
--------------------编程问答-------------------- 我刚开始用myeclipse10也遇到过这个问题,一访问action就报404,后来看了看web.xml,里面的配置都没了,把老项目的web.xml拷过去就行了
补充:Java ,  Java EE
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,