Maven如何快速有效的定义dependency节点

Maven如何快速有效的定义dependency节点,第一次用maven的为就像真的是小白 一样

每每遇到一个好的方法都激动不已,可能对于大神的你来说不值得一提了拉

如图所示


[caption id="attachment_910" align="alignnone" width="663"]maven设置下载节点 maven设置下载节点[/caption]

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
找不到这两个类

那么在pom.xml里应该怎么设置呢

首先我们分析groupId,groupId是唯一的比如一个学校,所以这里应该是org.springframework

那么artifactId是什么,artifactId就像学校里的班级,比如高1班、高2班,就是artifactId是可以存在相同的,那么我们这里的artifactId又是什么呢?分析SpringMVC的所有包,我们发现只有spring-webmvc  和  spring-webmvc-portlet,因为我们的类名里有web.servlet,这说明是和web有关的

所以artifactId 就是 这两个,就是说我们这里要甚至两个dependency节点,一个是spring-webmvc,一个是spring-webmvc-portlet

version就是版本号拉

最终的代码如下:

    <dependency>
    	<groupId>org.springframework</groupId>
      <artifactId>spring-webmvc</artifactId>
      <version>4.1.6.RELEASE</version>
    </dependency>
    <dependency>
    	<groupId>org.springframework</groupId>
      <artifactId>spring-webmvc-portlet</artifactId>
      <version>4.1.6.RELEASE</version>
    </dependency>


爆款云服务器s6 2核4G 低至0.46/天,具体规则查看活动详情Blog Img