使用IntelliJ IDEA搭建SSM框架的图文教程

网友投稿 231 2023-02-03


使用IntelliJ IDEA搭建SSM框架的图文教程

1.使用IDEA新建项目

2.选择创建Maven工程

3.填写GroupId和ArtifactId

4.填写项目名称,与上一步的ArtifactId一致即可,然后点Finish

5.刚建好的目录只是一个Maven的目录结构,如下

6.完善目录结构,添加webapp、WEB-INF目录,以及web.xml文件

7.修改IDEA的Maven设置,Maven默认的本地仓库会保存在C盘,为了方便以后使用,尽量修改本地仓库的位置,因为这是框架整合,所以具体的修改方式在这里不多做说明。快捷键ctrl+alt+s,在搜索框中搜索Maven,如下

9.修改Maven的核心配置文件pom.xml,添加框架所需要的依赖

xmlns:xsi="http://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">

4.0.0

com.xiao

SSM

1.0-SNAPSHOT

war

4.2.4.RELEASE

3.2.8

1.2.2

1.6.4

1.2.17

2.4.2

1.0.9

5.1.32

1.2

2.5

2.0

1.3.2

1.3.1

org.springframework

spring-context

${spring.version}

org.springframework

spring-beans

${spring.version}

org.springframework

spring-webmvc

${spring.version}

org.springframework

spring-jdbc

${spring.version}

org.springframework

spring-aspects

${spring.version}

org.springframework

spring-jms

${spring.version}

org.springframework

spring-context-support

${spring.version}

org.mybatis

mybatis

${mybatis.version}

org.mybatis

mybatis-spring

${mybatis.spring.version}

org.slf4j

slf4j-log4j12

${slf4j.version}

log4j

log4j

${log4j.version}

com.fasterxml.jackson.core

jackson-databind

${jackson.version}

com.alibaba

druid

${druid.version}

mysql

mysql-connector-java

${mysql.version}

org.apache.commons

commons-io

${commons-io.version}

commons-fileupload

commons-fileupload

${commons-fileupload.version}

jstl

jstl

${jstl.version}

javax.servlet

servlet-api

${servlet-api.version}

provided

javax.servlet

jsp-api

${jsp-api.version}

provided

org.springframework

spring-context

org.springframework

spring-beans

org.springframework

spring-webmvc

org.springframework

spring-jdbc

org.springframework

spring-aspechttp://ts

org.springframework

spring-jms

org.springframework

spring-context-support

org.mybatis

mybatis

org.mybatis

mybatis-spring

org.slf4j

slf4j-log4j12

com.fasterxml.jackson.core

jackson-databind

com.alibaba

druid

mysql

mysql-connector-java

org.apache.commons

commons-io

commons-fileupload

commons-fileupload

jstl

jstl

javax.servlet

servlet-api

provided

javax.servlet

jsp-api

provided

org.apache.maven.plugins

maven-compiler-plugin

3.2

1.8

1.8

UTF-8

src/main/java

**/*.xml

false

src/main/resources

**/*.properties

**/*.xml

false

xmlns:xsi="http://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">

4.0.0

com.xiao

SSM

1.0-SNAPSHOT

war

4.2.4.RELEASE

3.2.8

1.2.2

1.6.4

1.2.17

2.4.2

1.0.9

5.1.32

1.2

2.5

2.0

1.3.2

1.3.1

org.springframework

spring-context

${spring.version}

org.springframework

spring-beans

${spring.version}

org.springframework

spring-webmvc

${spring.version}

org.springframework

spring-jdbc

${spring.version}

org.springframework

spring-aspects

${spring.version}

org.springframework

spring-jms

${spring.version}

org.springframework

spring-context-support

${spring.version}

org.mybatis

mybatis

${mybatis.version}

org.mybatis

mybatis-spring

${mybatis.spring.version}

org.slf4j

slf4j-log4j12

${slf4j.version}

log4j

log4j

${log4j.version}

com.fasterxml.jackson.core

jackson-databind

${jackson.version}

com.alibaba

druid

${druid.version}

mysql

mysql-connector-java

${mysql.version}

org.apache.commons

commons-io

${commons-io.version}

commons-fileupload

commons-fileupload

${commons-fileupload.version}

jstl

jstl

${jstl.version}

javax.servlet

servlet-api

${servlet-api.version}

provided

javax.servlet

jsp-api

${jsp-api.version}

provided

org.springframework

spring-context

org.springframework

spring-beans

org.springframework

spring-webmvc

org.springframework

spring-jdbc

org.springframework

spring-aspechttp://ts

org.springframework

spring-jms

org.springframework

spring-context-support

org.mybatis

mybatis

org.mybatis

mybatis-spring

org.slf4j

slf4j-log4j12

com.fasterxml.jackson.core

jackson-databind

com.alibaba

druid

mysql

mysql-connector-java

org.apache.commons

commons-io

commons-fileupload

commons-fileupload

jstl

jstl

javax.servlet

servlet-api

provided

javax.servlet

jsp-api

provided

org.apache.maven.plugins

maven-compiler-plugin

3.2

1.8

1.8

UTF-8

src/main/java

**/*.xml

false

src/main/resources

**/*.properties

**/*.xml

false

10.在resources目录下添加配置文件

文件目录如下

a)连接数据库配置信息文件-db.properties

druid.driver=com.mysql.jdbc.Driver

druid.url=jdbc:mysql://localhost:3306/all_db?characterEncoding=utf-8

druid.username=root

druid.password=root

b)Mybatis核心配置文件-SqlMapConfig.xml

PUBLIC "-//mybatis.org//DTD Config 3.0//EN"

"http://mybatis.org/dtd/mybatis-3-config.dtd">

c)Spring核心配置文件,整合Mybatis,applicationContext.xml

xmlns="http://springframework.org/schema/beans"

xmlns:context="http://springframework.org/schema/context"

xmlns:tx="http://springframework.org/schema/tx"

xsi:schemaLocation="http://springframework.org/schema/beans http://springframework.org/schema/beans/spring-beans-4.2.xsd

http://springframework.org/schema/context http://springframework.org/schema/context/spring-context-4.2.xsd

http://springframework.org/schema/tx http://springframework.org/schema/tx/spring-tx-4.2.xsd">

xmlns="http://springframework.org/schema/beans"

xmlns:context="http://springframework.org/schema/context"

xmlns:tx="http://springframework.org/schema/tx"

xsi:schemaLocation="http://springframework.org/schema/beans http://springframework.org/schema/beans/spring-beans-4.2.xsd

http://springframework.org/schema/context http://springframework.org/schema/context/spring-context-4.2.xsd

http://springframework.org/schema/tx http://springframework.org/schema/tx/spring-tx-4.2.xsd">

d)SpringMVC配置文件-springmvc.xml

xmlns="http://springframework.org/schema/beans"

xmlns:context="http://springframework.org/schema/context"

xmlns:mvc="http://springframework.org/schema/mvc"

xsi:schemaLocation="http://springframework.org/schema/beans http://springframework.org/schema/beans/spring-beans-4.2.xsd

http://springframework.org/schema/context http://springframework.org/schema/context/spring-context-4.2.xsd

http://springframework.org/schema/mvc http://springframework.org/schema/mvc/spring-mvc-4.2.xsd">

xmlns="http://springframework.org/schema/beans"

xmlns:context="http://springframework.org/schema/context"

xmlns:mvc="http://springframework.org/schema/mvc"

xsi:schemaLocation="http://springframework.org/schema/beans http://springframework.org/schema/beans/spring-beans-4.2.xsd

http://springframework.org/schema/context http://springframework.org/schema/context/spring-context-4.2.xsd

http://springframework.org/schema/mvc http://springframework.org/schema/mvc/spring-mvc-4.2.xsd">

11.配置web.xml文件

xmlns:xsi="http://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"

version="2.5">

SSM

index.jsp

org.springframework.web.context.ContextLoaderListener

contextConfigLocation

classpath:applicationContext.xml

encoding

org.springframework.web.filter.CharacterEncodingFilter

encoding

UTF-8

encoding

/*

springmvc

org.springframework.web.servlet.DispatcherServlet

contextConfigLocation

classpath:springmvc.xml

1

springmvc

/

xmlns:xsi="http://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"

version="2.5">

SSM

index.jsp

org.springframework.web.context.ContextLoaderListener

contextConfigLocation

classpath:applicationContext.xml

encoding

org.springframework.web.filter.CharacterEncodingFilter

encoding

UTF-8

encoding

/*

springmvc

org.springframework.web.servlet.DispatcherServlet

contextConfigLocation

classpath:springmvc.xml

1

springmvc

/

12.完善目录结构,书写实体类、web层、service层、dao层以及测试页面,目录结构如下

13.配置tomcat

14.启动Tomcat,访问地址: http://localhost:8080/getAll   进行测试,结果如下

出现以上结果,表示SSM框架搭建成功!

数据库数据如下

在jsp页面用EL表达式取值

总结

以上所述是给大家介绍的使用IntelliJ IDEA搭建SSM框架的图文教程,希望对大家有所帮助,如果大家有任何疑问请给我留言,会及时回复大家的。在此也非常感谢大家对我们网站的支持!


版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:java怎么看线程状态(怎么看线程运行的状态数据)
下一篇:以v
相关文章

 发表评论

暂时没有评论,来抢沙发吧~