首页 > 编程语言 > 详细

SpringMVC+Spring+mybatis 项目实践

时间:2020-06-24 17:02:42      阅读:75      评论:0      收藏:0      [点我收藏+]

SpringMVC+Spring+mybatis 项目实践

 

1.生成项目

尝试了两种方法,一、利用https://start.spring.io/生成项目解压在,再用IDEA打开

 技术分享图片

二、是基于maven

 技术分享图片

注意配置maven的相关信息,前提需要自己安装maven

 技术分享图片

 

遇到的问题:项目生成后,IDEA自动下载库失败;

修改了maven 配置的镜像:

 技术分享图片

技术分享图片

 

 

镜像代码:

 

技术分享图片
<!-- mirrors
   | This is a list of mirrors to be used in downloading artifacts from remote repositories.
   |
   | It works like this: a POM may declare a repository to use in resolving certain artifacts.
   | However, this repository may have problems with heavy traffic at times, so people have mirrored
   | it to several places.
   |
   | That repository definition will have a unique id, so we can create a mirror reference for that
   | repository, to be used as an alternate download site. The mirror site will be the preferred
   | server for that repository.
   |-->
  <mirrors>
    <!-- mirror
     | Specifies a repository mirror site to use instead of a given repository. The repository that
     | this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
     | for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
     |
    <mirror>
      <id>mirrorId</id>
      <mirrorOf>repositoryId</mirrorOf>
      <name>Human Readable Name for this Mirror.</name>
      <url>http://my.repository.com/repo/path</url>
    </mirror>
     -->
      <mirror>
          <id>alimaven</id>
          <mirrorOf>central</mirrorOf>
          <name>aliyun maven</name>
          <url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
      </mirror>
      <mirror>
          <id>alimaven</id>
          <name>aliyun maven</name>
          <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
          <mirrorOf>central</mirrorOf>
      </mirror>
      <mirror>
          <id>central</id>
          <name>Maven Repository Switchboard</name>
          <url>http://repo1.maven.org/maven2/</url>
          <mirrorOf>central</mirrorOf>
      </mirror>
      <mirror>
          <id>repo2</id>
          <mirrorOf>central</mirrorOf>
          <name>Human Readable Name for this Mirror.</name>
          <url>http://repo2.maven.org/maven2/</url>
      </mirror>
      <mirror>
          <id>ibiblio</id>
          <mirrorOf>central</mirrorOf>
          <name>Human Readable Name for this Mirror.</name>
          <url>http://mirrors.ibiblio.org/pub/mirrors/maven2/</url>
      </mirror>
      <mirror>
          <id>jboss-public-repository-group</id>
          <mirrorOf>central</mirrorOf>
          <name>JBoss Public Repository Group</name>
          <url>http://repository.jboss.org/nexus/content/groups/public</url>
      </mirror>
      <mirror>
          <id>google-maven-central</id>
          <name>Google Maven Central</name>
          <url>
              https://maven-central.storage.googleapis.com
          </url>
          <mirrorOf>central</mirrorOf>
      </mirror>
      <!-- 中央仓库在中国的镜像 -->
      <mirror>
          <id>maven.net.cn</id>
          <name>oneof the central mirrors in china</name>
          <url>http://maven.net.cn/content/groups/public/</url>
          <mirrorOf>central</mirrorOf>
      </mirror>
  </mirrors>
View Code

 

然后就可以直接下载了。

 

2.导入相关依赖

 技术分享图片

 

3.导入前一个项目的资源

 技术分享图片

导入后注意修改各类包的引用路径,

4.创建mapper,修改数据库语句,并往所有servlet上添加 @Controller 的注解,转变为Spring MVC

 技术分享图片

实现效果:

技术分享图片

 技术分享图片

 

技术分享图片

技术分享图片 

 技术分享图片

码云地址:https://gitee.com/pinaomansgitee/SpringMVC.git

 

SpringMVC+Spring+mybatis 项目实践

原文:https://www.cnblogs.com/hjpsblog/p/13188115.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!