广告合作
  • 今日头条

    今日头条

  • 百度一下

    百度一下,你就知道

  • 新浪网

    新浪网 - 提供新闻线索,重大新闻爆料

  • 搜狐

    搜狐

  • 豆瓣

    豆瓣

  • 百度贴吧

    百度贴吧——全球领先的中文社区

  • 首页 尚未审核订阅工具 订阅

    如何在myeclipse中搭建ssm框架

    来源:网络收集  点击:  时间:2024-03-11
    【导读】:
    最简单的ssm框架搭建方法工具/原料more电脑myeclipse8.5方法/步骤1/8分步阅读

    首先呢 打开eclipse点击左上角的File--New--Report Web Project

    2/8

    然后在弹出的窗口输入项目名称 点击Finish

    3/8

    项目结构

    4/8

    接下来呢我们直接生成Spring 在项目上右击 选择 Myeclipse--Add Spring Cababilities 之后会弹出窗口(如图) 然后勾选JDBC(它会自动勾选三个)之后再勾选一个web3.0,再点击finish

    5/8

    现在的项目结构

    6/8

    之后我们再配置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 welcome-file-list welcome-fileindex.jsp/welcome-file /welcome-file-list filter filter-nameencoding/filter-name filter-classorg.springframework.web.filter.CharacterEncodingFilter/filter-class init-param param-nameencoding/param-name param-valueUTF-8/param-value /init-param /filter filter-mapping filter-nameencoding/filter-name url-pattern/*/url-pattern /filter-mapping!-- springmvc的核心控制器 -- servlet servlet-namespringDispatcher/servlet-name servlet-classorg.springframework.web.servlet.DispatcherServlet/servlet-class init-param param-namecontextConfigLocation/param-name param-valueclasspath:applicationContext.xml/param-value /init-param load-on-startup0/load-on-startup /servlet servlet-mapping servlet-namespringDispatcher/servlet-name url-pattern*.do/url-pattern /servlet-mapping !-- 启动spring -- listener listener-classorg.springframework.web.context.ContextLoaderListener/listener-class /listener!--拿到配置文件 -- context-param param-namecontextConfigLocation/param-name param-valueclasspath:applicationContext.xml/param-value /context-param /web-app

    7/8

    然后是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:mvc=http://www.springframework.org/schema/mvc xmlns:context=http://www.springframework.org/schema/context xmlns:tx=http://www.springframework.org/schema/tx xmlns:aop=http://www.springframework.org/schema/aop xsi:schemaLocation=http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-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/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd !-- 开启注解 -- context:annotation-config/ !-- 扫描包设置 -- context:component-scan base-package=com.tbdz.*/ !-- 启用3.0新注解 -- mvc:annotation-driven / !-- 启动Spring MVC的注解功能,完成请求和注解POJO的映射 -- bean class=org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter/ !-- 配置数据源 -- context:property-placeholder location=classpath:jdbc.properties/ bean id=dataSource class=org.apache.commons.dbcp.BasicDataSource property name=username value=${jdbc.user}/property property name=password value=${jdbc.password}/property property name=driverClassName value=${jdbc.driverClass}/property property name=url value=${jdbc.url}/property property name=maxActive value=100 /property property name=maxIdle value=30 /property property name=maxWait value=10000 /property /bean bean id=sqlSessionFactory class=org.mybatis.spring.SqlSessionFactoryBean property name=dataSource ref=dataSource/ property name=configLocation value=classpath:mybatis-config.xml/ /bean bean id=txManager class=org.springframework.jdbc.datasource.DataSourceTransactionManager property name=dataSource ref=dataSource/property /bean aop:config aop:pointcut id=bussinessService expression=execution(public * com.tbdz.service.*.*(..))/ aop:advisor pointcut-ref=bussinessService advice-ref=txAdvice / /aop:config tx:advice id=txAdvice transaction-manager=txManager tx:attributes tx:method name=add* propagation=REQUIRED/ tx:method name=update* propagation=REQUIRED / tx:method name=insert* propagation=REQUIRED / tx:method name=del* propagation=REQUIRED / tx:method name=edit* propagation=REQUIRED / tx:method name=* propagation=REQUIRED / /tx:attributes /tx:advice context:component-scan base-package=com.tbdz.*//beans

    8/8

    到这里就基本完事啦 然后再改下你自己的包名 ;再配置下映射文件就ok

    注意事项

    注意修改包名以及数据库

    本文关键词:

    版权声明:

    1、本文系转载,版权归原作者所有,旨在传递信息,不代表看本站的观点和立场。

    2、本站仅提供信息发布平台,不承担相关法律责任。

    3、若侵犯您的版权或隐私,请联系本站管理员删除。

    4、文章链接:http://www.1haoku.cn/art_321162.html

    相关资讯

    ©2019-2020 http://www.1haoku.cn/ 国ICP备20009186号05-05 22:52:01  耗时:0.027
    0.027s