SSM项目搭建测试的

本文介绍了如何在IDEA中利用SSM(Spring、SpringMVC、MyBatis)和Maven搭建项目。从新建项目开始,详细讲述了配置pom.xml文件、设置资源文件夹、创建Web.xml、构建包结构、实现Mapper、Service和Controller的过程,最后到运行Tomcat启动项目。

SSM +Maven+IDEA

1新建项目
在这里插入图片描述
在这里插入图片描述

2 pom


<spring.version>4.3.8.RELEASE</spring.version>

<dependencies>
  <!-- Spring相关包 -->
org.springframework spring-core ${spring.version} org.springframework spring-aop ${spring.version} org.springframework spring-web ${spring.version} org.springframework spring-webmvc ${spring.version} org.springframework spring-jdbc ${spring.version} org.springframework spring-tx ${spring.version} org.aspectj aspectjrt 1.8.0 org.aspectj aspectjweaver 1.8.0 javax.servlet javax.servlet-api 3.1.0 provided org.mybatis mybatis 3.3.0 mysql mysql-connector-java 5.1.26 com.alibaba druid 1.0.20 org.mybatis mybatis-spring 1.2.3 javax.servlet jstl 1.2 log4j log4j 1.2.17 org.slf4j slf4j-api 1.7.21 junit junit 3.8.1 test
</dependencies>

<build>
  
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.7</source>
                <target>1.7</target>
            </configuration>
        </plugin>
        <plugin>
			<groupId>org.apache.tomcat.maven</groupId>
			<artifactId>tomcat7-maven-plugin</artifactId>
			<version>2.2</version>
			<!--控制tomcat端口号 -->
			<configuration>
				<port>8080</port>
				<path>/</path>
				<uriEncoding>UTF-8</uriEncoding>		
			</configuration>
		</plugin>
        
    </plugins>
src/main/java **/*.properties **/*.xml false src/main/resources
</build>

3 资源文件新建src/main/resources
3.1 复制4个文件到src/main/resources

3.2 修改文件夹类型

3.3 Web.xml

<?xml version="1.0" encoding="UTF-8"?>


contextConfigLocation classpath:applicationContext-*.xml org.springframework.web.context.ContextLoaderListener spring_mvc org.springframework.web.servlet.DispatcherServlet contextConfigLocation classpath:springmvc-servlet.xml 1
<servlet-mapping>
<servlet-name>spring_mvc</servlet-name>
<!-- 也可以写/ 但所有资源路径都有问题 -->
<url-pattern>/</url-pattern>
60 index.jsp

3.4 新建 main --java文件夹

3.5 新建所有包

4 mapper+pojo
复制

5 service 接口 实现类
调用 mapper

6 Controller

7 运行项目
Tomcat7:run

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值