how2j.cn

下载区
文件名 文件大小
ssm.rar 20k
步骤 1 : 基于前面的知识点   
步骤 2 : 创建maven web项目   
步骤 3 : 设置项目目录   
步骤 4 : 选择Archetype   
步骤 5 : 设置GroupId和Artifact Id   
步骤 6 : 项目截图   
步骤 7 : 创建java 源代码目录   
步骤 8 : java源文件目录创建好了   
步骤 9 : pom.xml   
步骤 10 : 接着复制项目文件   
步骤 11 : web.xml   
步骤 12 : jsp 目录   
步骤 13 : 配置文件   
步骤 14 : java源代码   
步骤 15 : 关于Category.xml   
步骤 16 : 启动Tomcat   
步骤 17 : 访问测试地址   
步骤 18 : 可运行项目   

步骤 1 :

基于前面的知识点

edit edit
本知识点在SSM 的PageHelper的基础上进行,所以要先到SSM 的PageHelper去下载可运行的项目,并解压。

注: 不要下载到当前知识点的可运行项目了哦,当前的是已经完成了目前的步骤流程后完成的项目
步骤 2 :

创建maven web项目

edit edit
File->New->Other->Maven->Maven Project
创建maven web项目
步骤 3 :

设置项目目录

edit edit
默认即可
设置项目目录
选择 maven-archetype-webapp
选择Archetype
步骤 5 :

设置GroupId和Artifact Id

edit edit
设置GroupId和Artifact Id,分别是com.how2javassm
后续配置也是用的这个,所以照着做,别自作聪明改其他的,不然后面走不通
设置GroupId和Artifact Id
此时项目就创建好了,不过还会报错,接着做后续的一系列操作
项目截图
步骤 7 :

创建java 源代码目录

edit edit
在上一步的截图中可以发现,没有地方存放java源文件,这个时候就需要按照如下步骤做:
右键项目->属性->Java Build Path->Libraries->Edit->Workspace default
JRE(jdk8)->Finish
创建java 源代码目录
步骤 8 :

java源文件目录创建好了

edit edit
java源文件目录创建好了
接着复制粘贴pom.xml为下面的代码。 粘贴之后,jsp本来的报错就消失了,不过出来一个新的问题,要求通过Maven更新项目。

右键项目->Maven->Update Project,会弹出一个对话框,点击Ok,这个问题就消失了。
pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.how2java</groupId> <artifactId>ssm</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>war</packaging> <properties> <spring.version>4.1.3.RELEASE</spring.version> <pagehelper.version>5.1.2-beta</pagehelper.version> <mysql.version>5.1.6</mysql.version> <mybatis.spring.version>1.2.3</mybatis.spring.version> <mybatis.version>3.1.1</mybatis.version> <junit.version>4.12</junit.version> <jstl.version>1.2</jstl.version> <jsqlparser.version>1.0</jsqlparser.version> <jackson.version>1.2.7</jackson.version> <servlet-api.version>3.1.0</servlet-api.version> <druid.version>1.0.18</druid.version> <log4j.version>1.2.16</log4j.version> <commons-logging.version>1.2</commons-logging.version> <commons-fileupload.version>1.2.1</commons-fileupload.version> <commons-io.version>1.3.2</commons-io.version> <commons-lang.version>2.6</commons-lang.version> <aopalliance.version>1.0</aopalliance.version> <mybatis-generator.version>1.3.5</mybatis-generator.version> </properties> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>${junit.version}</version> </dependency> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis</artifactId> <version>${mybatis.version}</version> </dependency> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis-spring</artifactId> <version>${mybatis.spring.version}</version> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>${mysql.version}</version> </dependency> <dependency> <groupId>com.alibaba</groupId> <artifactId>druid</artifactId> <version>${druid.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-test</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-beans</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-jdbc</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-aspects</artifactId> <version>${spring.version}</version> </dependency> <!-- JSP相关 --> <dependency> <groupId>jstl</groupId> <artifactId>jstl</artifactId> <version>${jstl.version}</version> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <version>${servlet-api.version}</version> <scope>provided</scope> </dependency> <!-- pageHelper --> <dependency> <groupId>com.github.pagehelper</groupId> <artifactId>pagehelper</artifactId> <version>${pagehelper.version}</version> </dependency> <!--jsqlparser--> <dependency> <groupId>com.github.jsqlparser</groupId> <artifactId>jsqlparser</artifactId> <version>${jsqlparser.version}</version> </dependency> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>${log4j.version}</version> </dependency> <dependency> <groupId>commons-logging</groupId> <artifactId>commons-logging</artifactId> <version>${commons-logging.version}</version> </dependency> <dependency> <groupId>commons-fileupload</groupId> <artifactId>commons-fileupload</artifactId> <version>${commons-fileupload.version}</version> </dependency> <dependency> <groupId>commons-io</groupId> <artifactId>commons-io</artifactId> <version>${commons-io.version}</version> </dependency> <dependency> <groupId>commons-lang</groupId> <artifactId>commons-lang</artifactId> <version>${commons-lang.version}</version> </dependency> <dependency> <groupId>aopalliance</groupId> <artifactId>aopalliance</artifactId> <version>${aopalliance.version}</version> </dependency> <dependency> <groupId>org.mybatis.generator</groupId> <artifactId>mybatis-generator-core</artifactId> <version>${mybatis-generator.version}</version> </dependency> </dependencies> <build> <finalName>${project.artifactId}</finalName> <plugins> <!-- 资源文件拷贝插件 --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> <version>2.7</version> <configuration> <encoding>UTF-8</encoding> </configuration> </plugin> <!-- java编译插件 --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.2</version> <configuration> <source>1.8</source> <target>1.8</target> <encoding>UTF-8</encoding> </configuration> </plugin> </plugins> <pluginManagement> <plugins> <!-- 配置Tomcat插件 --> <plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> <version>2.2</version> </plugin> </plugins> </pluginManagement> <resources> <resource> <directory>src/main/resources</directory> <includes> <include>**/*.properties</include> <include>**/*.xml</include> <include>**/*.tld</include> </includes> <filtering>false</filtering> </resource> <resource> <directory>src/main/java</directory> <includes> <include>**/*.properties</include> <include>**/*.xml</include> </includes> <filtering>false</filtering> </resource> </resources> </build> </project>
步骤 10 :

接着复制项目文件

edit edit
首先从在基于前面的知识点里下载的项目里解压出来,然后按照如下顺序复制粘贴。 不要一股脑全粘贴进去,会出现无法解决的错误哦
首先覆盖web.xml
把下载下来的xxx/ssm/WebContent/WEB-INF/web.xml
复制到当前的 ssm/src/main/webapp/web.xml这里
web.xml
接着复制jsp目录。
千万不要复制lib目录
jsp 目录
把三个配置文件复制到 ssm/src/main/resources下面
配置文件
把java源代码复制到src/main/java下
java源代码
步骤 15 :

关于Category.xml

edit edit
按照maven ssm项目风格来说,这个文件本应该放在Resource目录的mapper文件夹下,但是这么做还要修改配置信息,为了避免问题复杂化,而且考虑到即使放在当前位置也是可以正常工作的,所以就暂时不修改它的位置了。
关于Category.xml
右键点击项目,点击Run As -> Run on Server 启动Tomcat

如果对于Eclipse内置Tomcat配置方式不熟悉,请参考教程:通过Eclipse启动Tomcat-Run On Server
步骤 17 :

访问测试地址

edit edit
访问如下测试地址:


http://localhost:8080/ssm/listCategory
访问测试地址
在右上角有本知识点对应的可运行项目下载 ,实在自己搞不出来,就下载解压出来比较一下。

注:不要和基于前面的知识点里的下载搞混了哦


HOW2J公众号,关注后实时获知最新的教程和优惠活动,谢谢。


提问已经提交成功,正在审核。 请于 我的提问 处查看提问记录,谢谢
关于 工具和中间件-Maven-创建 SSM 项目 的提问

尽量提供截图代码异常信息,有助于分析和解决问题。 也可进本站QQ群交流: 982790551
提问尽量提供完整的代码,环境描述,越是有利于问题的重现,您的问题越能更快得到解答。
对教程中代码有疑问,请提供是哪个步骤,哪一行有疑问,这样便于快速定位问题,提高问题得到解答的速度
在已经存在的几千个提问里,有相当大的比例,是因为使用了和站长不同版本的开发环境导致的,比如 jdk, eclpise, idea, mysql,tomcat 等等软件的版本不一致。
请使用和站长一样的版本,可以节约自己大量的学习时间。 站长把教学中用的软件版本整理了,都统一放在了这里, 方便大家下载: https://how2j.cn/k/helloworld/helloworld-version/1718.html

上传截图