IDEA使用maven创建SSM及其依赖的导入

$.说明:

1.IDEA创建maven SSM web项目

2.导入依赖

一.IDEA创建maven SSM项目

对于初入IDEA的人来说此篇博客适用于不会创建maven 项目的人

首先下载IDEA  附上官方网站:https://www.jetbrains.com/idea/download/#section=windows    

在这里不再演示破解IDEA的方法和安装方法。

    本人用的2018.2.3的版本 首先 创建一个新项目 点击   Create New Project

 

1.进入新建项目的界面 找到 maven项目

2.有很多创建maven项目的方法,博主不建议新手去勾选这个选项(maven模板)这个地方不勾。

3.找到你安装的jdk已经有的可以跳过这一步。没有的 点击 New找到你安装jdk的目录。

4.点击next

1.这里GruupId 和 ArtfactId 不做多余讲解  附上一个链接:https://blog.csdn.net/zhangxingyu126/article/details/81013315  

2.版本号默认即可 。

3.next

1. 填写项目的名称 和项目所放的路径   在GruupId 和 ArtfactId 中我填写的“ceshi” 所以下面自动出现的

可以根据自己的喜欢定义合法的命名。

2.点击完成。

1.项目名称

2.源代码等结构目录

3.maven填写依赖的jar包的xml(自动导入依赖的jar包配置写入其中)

4.选择画圈的自动导入jar包(只需要在pom.xml中添加依赖,可以自动下载)

1.点击这个图标 弹出(Project Structure)

2.另一种方法 :点击file >>  Project Structure   同样弹出

‘3,选择modules  

4.点击“+”  下滑

5.选择 Web 

1可以更换为自己设定的合法的命名。完成点击  OK。

1.在pom.xml文件中加入如下代码  jIDEA自动会下载所需要的jar包

附上 maven仓库地址  ;https://mvnrepository.com/    ( 右下角显示下载进度条)      

 1 <dependencies>
 2 <!--Spring MVC 及其依赖包-->
 3     <dependency>
 4         <groupId>org.springframework</groupId>
 5         <artifactId>spring-webmvc</artifactId>
 6         <version>5.0.3.RELEASE</version>
 7     </dependency>
 8     <dependency>
 9         <groupId>org.aspectj</groupId>
10         <artifactId>aspectjweaver</artifactId>
11         <version>1.9.2</version>
12     </dependency>
13     <dependency>
14         <groupId>org.springframework</groupId>
15         <artifactId>spring-jdbc</artifactId>
16         <version>5.0.3.RELEASE</version>
17     </dependency>
18     <!-- springmvc 默认使用jstl 标签 -->
19     <dependency>
20         <groupId>javax.servlet</groupId>
21         <artifactId>jstl</artifactId>
22         <version>1.2</version>
23     </dependency>
24     <!-- mybatis 核心包 -->
25     <dependency>
26         <groupId>org.mybatis</groupId>
27         <artifactId>mybatis</artifactId>
28         <version>3.4.5</version>
29     </dependency>
30 
31     <!-- mybatis 与 spring 的整合包 -->
32     <dependency>
33         <groupId>org.mybatis</groupId>
34         <artifactId>mybatis-spring</artifactId>
35         <version>1.3.2</version>
36     </dependency>
37     <!-- 配置连接mysql 的驱动包 -->
38     <dependency>
39         <groupId>mysql</groupId>
40         <artifactId>mysql-connector-java</artifactId>
41         <version>5.1.6</version>
42     </dependency>
43     <dependency>
44         <groupId>commons-logging</groupId>
45         <artifactId>commons-logging</artifactId>
46         <version>1.1.3</version>
47     </dependency>
48     <!-- https://mvnrepository.com/artifact/log4j/log4j -->
49     <dependency>
50         <groupId>log4j</groupId>
51         <artifactId>log4j</artifactId>
52         <version>1.2.17</version>
53     </dependency>
54     <dependency>
55         <groupId>org.slf4j</groupId>
56         <artifactId>slf4j-log4j12</artifactId>
57         <version>1.7.2</version>
58     </dependency>
59     <dependency>
60         <groupId>javax.servlet</groupId>
61         <artifactId>javax.servlet-api</artifactId>
62         <version>3.1.0</version>
63         <scope>provided</scope>
64     </dependency>
65     <dependency>
66         <groupId>javax.servlet.jsp</groupId>
67         <artifactId>javax.servlet.jsp-api</artifactId>
68         <version>2.3.1</version>
69         <scope>provided</scope>
70     </dependency>
71 
72 </dependencies>

 

 

 $总结

这种创建方式不使用maven模板

IDEA对于快速编写代码具有很高的效率,

本文关于GruupId 和 ArtfactId 没有讲明实际作用。

如果不会 maven 和 IDEA 的也可以使用 。

对于创建后的 .idea文件 可在设置中隐藏 。所以我没有显示.idea文件

 

转载于:https://www.cnblogs.com/CllOVER/p/10246656.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: 这个问题是让我介绍如何使用Maven构建SSM项目。 首先,我们需要在pom.xml文件中添加SSM框架的依赖项,例如spring-webmvc,mybatis-spring等。然后,我们还需要在配置文件中设置相关的数据源,事务管理器等。 最后,我们可以使用Maven构建项目并生成war文件。 通过将war文件部署到服务器上,我们就可以使用SSM框架开发我们的应用程序了。 ### 回答2: Idea 是一款很好用的 Java IDE 工具,而 SSM 是 Spring + SpringMVC + MyBatis 的框架结构。在开发基于 SSM 框架的 Java 项目时,我们通常会使用Maven 来管理项目中的依赖。因此,如何在 Idea导入 SSM 项目,并使用 Maven 进行依赖管理,这是非常值得我们关注和学习的。 首先,我们需要在 Idea创建一个 Maven 项目。在 File 菜单下选择 New Project,选择 Maven 类型,如下图所示: ![创建Maven项目.png](https://i.loli.net/2021/06/25/SWIDaKZPVvzXj7Y.png) 接着,在创建项目时可以指定相关信息,如项目的 GroupId、ArtifactId 和版本号,如下图所示: ![Maven项目详细信息.png](https://i.loli.net/2021/06/25/5f4PMtH3kZvqdjJ.png) 创建好项目之后,我们需要在 pom.xml 中添加 SSM 框架以及其他依赖包的信息。在 pom.xml 文件中,我们需要添加如下的配置项: ``` xml <dependencies> <!-- Spring 框架依赖 --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> <version>5.3.3</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> <version>5.3.3</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-beans</artifactId> <version>5.3.3</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>5.3.3</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-jdbc</artifactId> <version>5.3.3</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-tx</artifactId> <version>5.3.3</version> </dependency> <!-- SpringMVC 框架依赖 --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>5.3.3</version> </dependency> <!-- Mybatis 框架依赖 --> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis</artifactId> <version>3.5.6</version> </dependency> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis-spring</artifactId> <version>2.0.6</version> </dependency> <!-- 数据库驱动依赖 --> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>8.0.23</version> </dependency> <!-- Servlet API 及 JSP API 依赖(容器提供) --> <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <version>4.0.1</version> <scope>provided</scope> </dependency> <dependency> <groupId>javax.servlet.jsp</groupId> <artifactId>javax.servlet.jsp-api</artifactId> <version>2.3.3</version> <scope>provided</scope> </dependency> </dependencies> ``` 在配置好依赖之后,我们需要在项目的 src 目录下建立相应的文件夹和文件,如下图所示: ![SSM项目目录结构.png](https://i.loli.net/2021/06/25/kOwQRrJUo6u5Hd1.png) 其中,包含三个主要部分: - controller : 存放控制器类 - entity : 存放实体类 - mapper : 存放 Mybatis 映射器 在建立好项目的目录结构之后,我们还需要在项目的 web.xml 文件中添加 SpringMVC 的配置,如下图所示: ![web.xml.png](https://i.loli.net/2021/06/25/HOdKjwUD63BhXPv.png) 至此,我们已经完成了在 Idea导入 SSM 项目,以及使用 Maven 进行依赖管理的过程。通过学习这个过程,我们能够更好的理解 SSM 框架的结构和原理,也能够更加熟悉 Maven 项目管理工具的使用方法。同时,我们也可以应用这些知识来实现更加复杂且功能强大的 Java Web 开发项目。 ### 回答3: SSM框架(Spring+SpringMVC+Mybatis)是目前主流的Java Web开发框架之一,Maven是管理Java项目构建和依赖的工具,在SSM项目使用Maven可以更方便地管理jar包,打包等操作。 导入Idea项目: 1. 打开Idea,选择File -> New -> Project 2. 选择Maven,注意先选择正确的Java版本 3. 输入项目信息,选择项目存放位置 4. 选择webapp,勾选Create from archetype,选择maven-archetype-webapp,点击Next 5. 输入GroupId和ArtifactId,点击Next,再点击Finish 6. 等待Idea下载依赖包,完成后会在项目中出现一个pom.xml文件 导入SSM框架: 1. 在pom.xml文件中添加以下依赖: ``` <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>5.2.9.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>5.2.9.RELEASE</version> </dependency> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis</artifactId> <version>3.5.6</version> </dependency> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis-spring</artifactId> <version>2.0.6</version> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>8.0.21</version> </dependency> ``` 2. 在项目中创建config文件夹,在其中创建spring.xml和mybatis.xml配置文件 3. 将spring.xml中配置SpringMVC的部分删除,只保留Spring的部分 4. 在spring.xml中引入mybatis.xml文件,配置Mybatis 5. 在web.xml中配置DispatcherServlet和CharacterEncodingFilter 6. 创建Controller和Mapper层,用于处理请求和数据库操作 7. 运行项目,查看是否正常运行 以上就是使用Idea导入SSM框架和Maven的详细教程。注意事项:在写配置文件时,注意路径正确,避免出现404错误;在配置Mybatis时,涉及到数据库的信息需要正确配置;在导入jar包时,版本号要与其他jar包版本兼容。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值