idea搭建SSM的maven项目(tomcat容器)

Posted 秋风飒飒吹

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了idea搭建SSM的maven项目(tomcat容器)相关的知识,希望对你有一定的参考价值。

一.创建maven的web项目

(1)选择项目的骨架

 

(2)写项目的坐标

(3)maven的设置

设置maven的本地仓库,以及配置文件的位置,同时点击+号,填入archetypeCatalog和internal,让maven读取本地配置即可(这样能让idea快速的创建maven的web工程)。

然后点击next

(4)创建完成

点击finish

二.添加目录并导入依赖

(一)添加java目录,main目录下创建java目录,并且将其标记为Sources Root

 

(2) 在main文件夹下创建resources目录,并将其标记为Resources Root

(如果有需要,可以在src目录下创建test文件夹,并创建java和resources文件夹,并将它们分别标记为Test Resources Root和Test Resources Root,这里就不创建了)

最后目录结构如下

(3)pom文件的编写(导入相关依赖)

maven.compiler.source和maven.compiler.target標簽中写jdk的版本

  1 <properties>
  2     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  3     <maven.compiler.source>1.8</maven.compiler.source> 
  4     <maven.compiler.target>1.8</maven.compiler.target>
  5 
  6     <!--定义版本号   ${org.springframework.version}-->
  7     <org.springframework.version>5.0.7.RELEASE</org.springframework.version>
  8     <org.mybatis.version>3.4.6</org.mybatis.version>
  9 
 10   </properties>
 11 
 12   <dependencies>
 13 
 14     <!--单元测试-->
 15     <dependency>
 16       <groupId>junit</groupId>
 17       <artifactId>junit</artifactId>
 18       <version>4.12</version>
 19       <scope>test</scope>
 20     </dependency>
 21     <!--lombok-->
 22     <dependency>
 23       <groupId>org.projectlombok</groupId>
 24       <artifactId>lombok</artifactId>
 25       <version>1.16.6</version>
 26     </dependency>
 27     <!-- servlet-api -->
 28     <dependency>
 29       <groupId>javax.servlet</groupId>
 30       <artifactId>servlet-api</artifactId>
 31       <version>2.5</version>
 32       <scope>provided</scope>
 33     </dependency>
 34     <!--mysql驱动-->
 35     <dependency>
 36       <groupId>mysql</groupId>
 37       <artifactId>mysql-connector-java</artifactId>
 38       <version>5.1.21</version>
 39     </dependency>
 40     <!-- druid -->
 41     <dependency>
 42       <groupId>com.alibaba</groupId>
 43       <artifactId>druid</artifactId>
 44       <version>1.0.14</version>
 45     </dependency>
 46     <!-- common-lang -->
 47     <dependency>
 48       <groupId>commons-lang</groupId>
 49       <artifactId>commons-lang</artifactId>
 50       <version>2.6</version>
 51     </dependency>
 52     <!--spring-test-->
 53     <dependency>
 54       <groupId>org.springframework</groupId>
 55       <artifactId>spring-test</artifactId>
 56       <version>${org.springframework.version}</version>
 57       <scope>test</scope>
 58     </dependency>
 59     <!--spring-core-->
 60     <dependency>
 61       <groupId>org.springframework</groupId>
 62       <artifactId>spring-core</artifactId>
 63       <version>${org.springframework.version}</version>
 64     </dependency>
 65     <!--spring-context-->
 66     <dependency>
 67       <groupId>org.springframework</groupId>
 68       <artifactId>spring-context</artifactId>
 69       <version>${org.springframework.version}</version>
 70     </dependency>
 71     <!--spring-context-support-->
 72     <dependency>
 73       <groupId>org.springframework</groupId>
 74       <artifactId>spring-context-support</artifactId>
 75       <version>${org.springframework.version}</version>
 76     </dependency>
 77     <!--spring-expression-->
 78     <dependency>
 79       <groupId>org.springframework</groupId>
 80       <artifactId>spring-expression</artifactId>
 81       <version>${org.springframework.version}</version>
 82     </dependency>
 83     <!--spring-jdbc-->
 84     <dependency>
 85       <groupId>org.springframework</groupId>
 86       <artifactId>spring-jdbc</artifactId>
 87       <version>${org.springframework.version}</version>
 88     </dependency>
 89     <!--spring-tx-->
 90     <dependency>
 91       <groupId>org.springframework</groupId>
 92       <artifactId>spring-tx</artifactId>
 93       <version>${org.springframework.version}</version>
 94     </dependency>
 95     <!--spring-web-->
 96     <dependency>
 97       <groupId>org.springframework</groupId>
 98       <artifactId>spring-web</artifactId>
 99       <version>${org.springframework.version}</version>
100     </dependency>
101     <!--spring-aop-->
102     <dependency>
103       <groupId>org.springframework</groupId>
104       <artifactId>spring-aop</artifactId>
105       <version>${org.springframework.version}</version>
106     </dependency>
107     <!--spring-webmvc-->
108     <dependency>
109       <groupId>org.springframework</groupId>
110       <artifactId>spring-webmvc</artifactId>
111       <version>${org.springframework.version}</version>
112     </dependency>
113 
114     <!-- aspectj -->
115     <dependency>
116       <groupId>org.aspectj</groupId>
117       <artifactId>aspectjrt</artifactId>
118       <version>1.7.4</version>
119     </dependency>
120     <!--aspectj weaver-->
121     <dependency>
122       <groupId>org.aspectj</groupId>
123       <artifactId>aspectjweaver</artifactId>
124       <version>1.7.4</version>
125     </dependency>
126 
127     <!-- cglib -->
128     <dependency>
129       <groupId>cglib</groupId>
130       <artifactId>cglib</artifactId>
131       <version>3.1</version>
132     </dependency>
133 
134     <!-- mybatis -->
135     <dependency>
136       <groupId>org.mybatis</groupId>
137       <artifactId>mybatis</artifactId>
138       <version>${org.mybatis.version}</version>
139     </dependency>
140     <!--mybatis-spring-->
141     <dependency>
142       <groupId>org.mybatis</groupId>
143       <artifactId>mybatis-spring</artifactId>
144       <version>1.3.0</version>
145     </dependency>
146 
147     <!-- jackson-core -->
148     <dependency>
149       <groupId>com.fasterxml.jackson.core</groupId>
150       <artifactId>jackson-core</artifactId>
151       <version>2.9.4</version>
152     </dependency>
153     <!--jackson-databind-->
154     <dependency>
155       <groupId>com.fasterxml.jackson.core</groupId>
156       <artifactId>jackson-databind</artifactId>
157       <version>2.9.4</version>
158     </dependency>
159     <!--jackson-annotations-->
160     <dependency>
161       <groupId>com.fasterxml.jackson.core</groupId>
162       <artifactId>jackson-annotations</artifactId>
163       <version>2.9.4</version>
164     </dependency>
165 
166     <!--slf4j-api-->
167     <dependency>
168       <groupId>org.slf4j</groupId>
169       <artifactId>slf4j-api</artifactId>
170       <version>1.7.6</version>
171     </dependency>
172     <!--slf4j-log4j12-->
173     <dependency>
174       <groupId>org.slf4j</groupId>
175       <artifactId>slf4j-log4j12</artifactId>
176       <version>1.7.6</version>
177     </dependency>
178     <!--log4j-->
179     <dependency>
180       <groupId>log4j</groupId>
181       <artifactId>log4j</artifactId>
182       <version>1.2.17</version>
183     </dependency>
184     <!--commons-fileupload-->
185     <dependency>
186       <groupId>commons-fileupload</groupId>
187       <artifactId>commons-fileupload</artifactId>
188       <version>1.3.1</version>
189     </dependency>
190     <!-- jstl -->
191     <dependency>
192       <groupId>jstl</groupId>
193       <artifactId>jstl</artifactId>
194       <version>1.2</version>
195     </dependency>
196     <!-- standard -->
197     <dependency>
198       <groupId>taglibs</groupId>
199       <artifactId>standard</artifactId>
200       <version>1.1.2</version>
201     </dependency>
202     <!--pagehelper-->
203     <dependency>
204       <groupId>com.github.pagehelper</groupId>
205       <artifactId>pagehelper</artifactId>
206       <version>4.1.4</version>
207     </dependency>
208 
209 
210   </dependencies>

(4) 配置文件的编写

创建基本的文件夹,并添加文件,如图

mybatis全局配置文件的编写,创建sqlMapConfig.xml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
        PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
    <settings>
        <setting name="logImpl" value="STDOUT_LOGG

以上是关于idea搭建SSM的maven项目(tomcat容器)的主要内容,如果未能解决你的问题,请参考以下文章

SSM简单搭建

IDEA搭建Maven Web(SSM)项目——创建项目

ssm框架搭建

使用idea搭建一个简单的SSM框架:使用idea创建maven项目

SSM项目整合,适合新手

bootstrap+Ajax+SSM(maven搭建)表单增删改查