导入spring mvc工程 并用tomcat启动

入职新公司,要熟悉现有的系统。之前只做过springboot+gradle的项目,这次是springmvc+maven。

springboot的启动方式就是在启动类点右键启动就OK了。

springmvc的启动方式不太一样。弄明白了以后发现自己以前也捣鼓过。

以前做对日的时候,研究过在eclipse里面用jboss启动项目,是先创建服务,然后在服务上跑工程。

 

第一步,安装maven

官网地址:http://maven.apache.org/download.cgi

windows的要这个zip

导入spring mvc工程 并用tomcat启动

解压到一个地方

导入spring mvc工程 并用tomcat启动

 

创建一个本地库

导入spring mvc工程 并用tomcat启动

配置文件配两个地方(镜像地址和本地库地址)

C:\apache-maven-3.6.3\conf\settings.xml

  <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>  
            <name>aliyun maven</name>  
            <url>http://maven.aliyun.com/nexus/content/groups/public/</url>  
            <mirrorOf>central</mirrorOf>          
     </mirror>

  </mirrors>

   <!-- localRepository
   | The path to the local repository maven will use to store artifacts.
   |
   | Default: ${user.home}/.m2/repository
  <localRepository>C:\apache-maven-3.6.3\repo</localRepository>
  -->
  <localRepository>/path/to/local/repo</localRepository>

环境变量也要配置,但是我配完了以后,mvn -v命令还是不起作用。但是 这并不影响使用。

导入spring mvc工程 并用tomcat启动

导入spring mvc工程 并用tomcat启动

然后再从Idea里面配置好maven安装路径和配置文件路径 

导入spring mvc工程 并用tomcat启动

 到这里,有一些找不到的依赖包就都可以下载了。在idea里面重新加载一下maven

导入spring mvc工程 并用tomcat启动

第二步,安装tomcat(我用的8)

官网:https://tomcat.apache.org/download-80.cgi

导入spring mvc工程 并用tomcat启动

解压到一个地方

导入spring mvc工程 并用tomcat启动

然后cmd运行安装命令(安装之前请务必装好jdk,配置好JAVA_HOME和Path)

C:\apache-tomcat-8.5.57\bin\service -install

额流程是后来补的,图就不贴了。

勾选一个tomcat的插件

导入spring mvc工程 并用tomcat启动

然后在Idea里面添加要启动的模块

导入spring mvc工程 并用tomcat启动

 

导入spring mvc工程 并用tomcat启动

 添加tomcat服务

导入spring mvc工程 并用tomcat启动

然后添加启动项目

导入spring mvc工程 并用tomcat启动

添加tomcat的jar包

导入spring mvc工程 并用tomcat启动

最后尝试启动

导入spring mvc工程 并用tomcat启动