java中的接口是类吗
352
2023-03-17
java整合SSM框架的图文教程
使用Myeclipse搭建maven项目
准备工作
安装maven
官网下载安装(http://maven.apache.org/)
配置环境变量
配置完后,使用命令行输入mvn -version查看是否配置成功,出现以下界面表示配置成功。
2. 在MyEclipse中配置maven
打开MyEclipse2015————点击菜单栏Window———选项栏Preference ,搜索Maven,进入Installations,点击Add引入安装的maven。
进入User Setting,设置Global Setting,选中安装的maven的settings.xml配置文件(以上步骤已经完成maven配置)
3. 创建项目(检测是否配置成功,这里创建的是web项目)
点击项目右键->Run as->Maven install将依赖install至本地maven库,有可能会报:
-Dmaven.multiModuleProjectDirectorysystem propery is not set. Check $M2_HOME environment variable and mvn scriptmatch.,
表示JDK版本和maven有冲突,更改一下jdk版本,并且加上-Dmaven.multiModuleProjectDirectory=$M2_HOME即可;
如运行过程中控制台如下图所示,表示成功。
在maven项目中搭建spring+springMVC+MyBatis
修改pom.xml添加对应的包依赖
&MzBXPlAlt;dependency>
MzBXPlA
修改web.xml,配置驱动及过滤器和加载Spring配置文件
创建并配置applicationContext.xml
xmlns:xsi="http://w3.org/2001/XMLSchema-instance" xmlns:p="http://springframework.org/schema/p" xmlns:tx="http://springframework.org/schema/tx" xmlns:context="http://springframework.org/schema/context" xmlns:aop="http://springframework.org/schema/aop" xmlns:jaxws="http://cxf.apache.org/jaxws" xsi:schemaLocation="http://springframework.org/schema/aop http://springframework.org/schema/aop/spring-aop-4.1.xsd http://springframework.org/schema/beans http://springframework.org/schema/beans/spring-beans-4.1.xsd http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd http://springframework.org/schema/tx http://springframework.org/schema/tx/spring-tx.xsd http://springframework.org/schema/context http://springframework.org/schema/context/spring-context-4.1.xsd"> class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> expression="execution(* cn.ft.service.impl.*Impl.*(..))" /> advice-ref="transactionAdvice" />
xmlns:xsi="http://w3.org/2001/XMLSchema-instance" xmlns:p="http://springframework.org/schema/p"
xmlns:tx="http://springframework.org/schema/tx" xmlns:context="http://springframework.org/schema/context"
xmlns:aop="http://springframework.org/schema/aop"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xsi:schemaLocation="http://springframework.org/schema/aop http://springframework.org/schema/aop/spring-aop-4.1.xsd
http://springframework.org/schema/beans http://springframework.org/schema/beans/spring-beans-4.1.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
http://springframework.org/schema/tx http://springframework.org/schema/tx/spring-tx.xsd
http://springframework.org/schema/context http://springframework.org/schema/context/spring-context-4.1.xsd">
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
expression="execution(* cn.ft.service.impl.*Impl.*(..))" /> advice-ref="transactionAdvice" />
expression="execution(* cn.ft.service.impl.*Impl.*(..))" />
advice-ref="transactionAdvice" />
advice-ref="transactionAdvice" />
创建并配置springmvc.xml
xmlns:xsi="http://w3.org/2001/XMLSchema-instance" xmlns:p="http://springframework.org/schema/p" xmlns:context="http://springframework.org/schema/context" xmlns:aop="http://springframework.org/schema/aop" xmlns:mvc="http://springframework.org/schema/mvc" xsi:schemaLocation="http://springframework.org/schema/aop http://springframework.org/schema/aop/spring-aop-4.3.xsd http://springframework.org/schema/mvc http://springframework.org/schema/mvc/spring-mvc-4.3.xsd http://springframework.org/schema/beans http://springframework.org/schema/beans/spring-beans-4.1.xsd http://springframework.org/schema/context http://springframework.org/schema/context/spring-context-4.1.xsd"> class="org.springframework.web.servlet.view.InternalResourceViewResolver"> class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver"> /refuse
xmlns:xsi="http://w3.org/2001/XMLSchema-instance"
xmlns:p="http://springframework.org/schema/p"
xmlns:context="http://springframework.org/schema/context"
xmlns:aop="http://springframework.org/schema/aop"
xmlns:mvc="http://springframework.org/schema/mvc"
xsi:schemaLocation="http://springframework.org/schema/aop http://springframework.org/schema/aop/spring-aop-4.3.xsd
http://springframework.org/schema/mvc http://springframework.org/schema/mvc/spring-mvc-4.3.xsd
http://springframework.org/schema/beans http://springframework.org/schema/beans/spring-beans-4.1.xsd
http://springframework.org/schema/context http://springframework.org/schema/context/spring-context-4.1.xsd">
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver"> /refuse
class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
/refuse
配置数据源db.properties
driverClassName=com.mysql.jdbc.Driver
validationQuery=SELECT 1
jdbc_url=jdbc\:mysql\://localhost\:3306/ft?useUnicode\=true&characterEncoding\=UTF-8&zeroDateTimeBehavior\=convertToNull
jdbc_username=root
jdbc_password=8888
配置mybatis-config.xm
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
配置log4j.properties
log4j.rootCategory=DEBUG, stdout , R
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=[QC] %p [%t] %C.%M(%L) | %m%n
log4j.appender.R=org.apache.log4j.DailyRollingFileAppender
log4j.appender.R.File=D\:\\Tomcat 5.5\\logs\\qc.log
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%d-[TS] %p %t %c - %m%n
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~