如何在myeclipse中搭建ssm框架

 时间:2024-10-25 17:17:37

最简单的ssm框架搭建方法

工具/原料

电脑

myeclipse8.5

方法/步骤

1、首先呢打开eclipse点击左上角的File-->New-->ReportWebProject

如何在myeclipse中搭建ssm框架

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

如何在myeclipse中搭建ssm框架

3、项目结构

如何在myeclipse中搭建ssm框架

4、接下来呢我们直接生成Spring在项目上右略居承柘击选择Myeclipse-->AddSpringCababil足毂忍珩ities之后会弹出窗口(如图)然后勾选JDBC(它会自动勾选三个)之后再勾选一个web3.0,再点击finish

如何在myeclipse中搭建ssm框架

如何在myeclipse中搭建ssm框架

如何在myeclipse中搭建ssm框架

如何在myeclipse中搭建ssm框架

5、现在的项目结构

如何在myeclipse中搭建ssm框架

6、之后我们再配置web.xml:<?xmlvers坡纠课柩ion="1.0"encoding=&鳎溻趄酃quot;UTF-8"?><web-appversion="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/javaeehttp://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"><welcome-file-list><welcome-file>index.jsp</welcome-file></welcome-file-list><filter><filter-name>encoding</filter-name><filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class><init-param><param-name>encoding</param-name><param-value>UTF-8</param-value></init-param></filter><filter-mapping><filter-name>encoding</filter-name><url-pattern>/*</url-pattern></filter-mapping><!--springmvc的核心控制器--><servlet><servlet-name>springDispatcher</servlet-name><servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class><init-param><param-name>contextConfigLocation</param-name><param-value>classpath:applicationContext.xml</param-value></init-param><load-on-startup>0</load-on-startup></servlet><servlet-mapping><servlet-name>springDispatcher</servlet-name><url-pattern>*.do</url-pattern></servlet-mapping><!--启动spring--><listener><listener-class>org.springframework.web.context.ContextLoaderListener</listener-class></listener><!--拿到配置文件--><context-param><param-name>contextConfigLocation</param-name><param-value>classpath:applicationContext.xml</param-value></context-param></web-app>

7、然后是applicationContext.xml:<?xmlvers坡纠课柩ion="1.0"惺绅寨瞀encoding="UTF-8"?><beansxmlns="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/beanshttp://www.springframework.org/schema/beans/spring-beans.xsdhttp://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context-3.0.xsdhttp://www.springframework.org/schema/txhttp://www.springframework.org/schema/tx/spring-tx-3.0.xsdhttp://www.springframework.org/schema/aophttp://www.springframework.org/schema/aop/spring-aop-3.0.xsdhttp://www.springframework.org/schema/mvchttp://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd"><!--开启注解--><context:annotation-config/><!--扫描包设置--><context:component-scanbase-package="com.tbdz.*"/><!--启用3.0新注解--><mvc:annotation-driven/><!--启动SpringMVC的注解功能,完成请求和注解POJO的映射--><beanclass="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"/><!--配置数据源--><context:property-placeholderlocation="classpath:jdbc.properties"/><beanid="dataSource"class="org.apache.commons.dbcp.BasicDataSource"><propertyname="username"value="${jdbc.user}"></property><propertyname="password"value="${jdbc.password}"></property><propertyname="driverClassName"value="${jdbc.driverClass}"></property><propertyname="url"value="${jdbc.url}"></property><propertyname="maxActive"value="100"></property><propertyname="maxIdle"value="30"></property><propertyname="maxWait"value="10000"></property></bean><beanid="sqlSessionFactory"class="org.mybatis.spring.SqlSessionFactoryBean"><propertyname="dataSource"ref="dataSource"/><propertyname="configLocation"value="classpath:mybatis-config.xml"/></bean><beanid="txManager"class="org.springframework.jdbc.datasource.DataSourceTransactionManager"><propertyname="dataSource"ref="dataSource"></property></bean><aop:config><aop:pointcutid="bussinessService"expression="execution(public*com.tbdz.service.*.*(..))"/><aop:advisorpointcut-ref="bussinessService"advice-ref="txAdvice"/></aop:config><tx:adviceid="txAdvice"transaction-manager="txManager"><tx:attributes><tx:methodname="add*"propagation="REQUIRED"/><tx:methodname="update*"propagation="REQUIRED"/><tx:methodname="insert*"propagation="REQUIRED"/><tx:methodname="del*"propagation="REQUIRED"/><tx:methodname="edit*"propagation="REQUIRED"/><tx:methodname="*"propagation="REQUIRED"/></tx:attributes></tx:advice><context:component-scanbase-package="com.tbdz.*"/></beans>

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

Navicat 如何导出数据 数据库er图怎么画 如何利用Navicat软件向mysql数据库中导出数据 IDEA怎么设置为白色背景 IntelliJ IDEA如何快捷生成类图
热门搜索
唐三彩图片 英伦汽车报价及图片 绝世唐门2漫画 风炫漫画 黄金项链图片