eclipse run pom xml集成spring Boot后建Maven工程,pom.xml文件报错,求原因和解决方法

在eclipse中使用maven构建Web项目时报错:maven-resources-plugin 解决方法
作者:用户
本文讲的是在eclipse中使用maven构建Web项目时报错:maven-resources-plugin 解决方法,
今天在一个新建的web项目中发生了以下错误:
Failed to read artifact descriptor for org.apache.maven.plugins:maven-resources-plugin
今天在一个新建的web项目中发生了以下错误:
Failed to read artifact descriptor for org.apache.maven.plugins:maven-resources-plugin
Eclipse的错误提示如下:
Could not calculate build plan: Plugin org.apache.maven.plugins:maven-resources-plugin:2.6 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-resources-plugin:jar:2.6
Plugin org.apache.maven.plugins:maven-resources-plugin:2.6 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-resources-plugin:jar:2.6
一开始以为是版本问题,因为看到eclipse内嵌有maven,而我自己系统也装了maven,所以改了ecplise里的maven home设置,错误依旧;
在baidu中搜了一下(老样子,除了你不想找的,很难找到你想找的技术资料,纯属发牢骚~哈哈);
baidu找到的资料:
1,可能是网络被墙,设置镜像;
2,可以试试重新下载maven-resources-
经过尝试1,没解决问题(甚至不小心增加了问题,这个怪我自己不够细心啦,可能复制的镜像配置里有非法字符),2,我下了旧一点的版本了,问题依旧;
问题解决的场景有点意向不到(其实很多问题最初解决场景都是意向不到的,hoho~),我直接在命令行打mvn compile,提示了与eclipse不一样的错误:
[ERROR] Error executing Maven.
[ERROR] 1 problem was encountered while building the effective settings
[FATAL] Non-parseable settings /usr/share/maven/conf/settings.xml: in comment after two dashes (--) next character must be & not
(position: START_TAG seen ...\n
&!-- ... @164:17)
@ /usr/share/maven/conf/settings.xml, line 164, column 17
上面的错误,是因为我增加了maven的镜像,当时就是直接复制于网络的配置项(但其实是注释掉的了)
删掉之后,再次compile,命令行中就没有问题了,回到eclipse中,刷新项目,继续报同样的错误!!!!!
到这里可以确定是eclipse部分的问题了,重新查看了eclipse的maven配置,发现没有指定全局配置(前面配置的镜像啥的都在全局配置文件里),立刻指定配置Preferences–&Maven–&User Settings–&Global Settings,指定到我的配置文件:/usr/share/maven/conf/settings.xml, 保存配置,刷新项目,提示下载maven的东东了,到此问题真正解决了~~~
后面贴网上找到的oschina的maven镜像配置(我自己没用,试了一下,速度:零点几K/S):
&!----这是全局镜像,记得放到mirrors位置--&
&id&nexus-osc&/id&
&mirrorOf&*&/mirrorOf&
&name&Nexus osc&/name&
&url&http://maven.oschina.net/content/groups/public/&/url&
&!--这是插件的,记得放到插件配置位置---&
&id&jdk-1.4&/id&
&activation&
&jdk&1.4&/jdk&
&/activation&
&repositories&
&repository&
&id&nexus&/id&
&name&local private nexus&/name&
&url&http://maven.oschina.net/content/groups/public/&/url&
&releases&
&enabled&true&/enabled&
&/releases&
&snapshots&
&enabled&false&/enabled&
&/snapshots&
&/repository&
&/repositories&
&pluginRepositories&
&pluginRepository&
&id&nexus&/id&
&name&local private nexus&/name&
&url&http://maven.oschina.net/content/groups/public/&/url&
&releases&
&enabled&true&/enabled&
&/releases&
&snapshots&
&enabled&false&/enabled&
&/snapshots&
&/pluginRepository&
&/pluginRepositories&
&/profile&
maven项目建立pom.xml报无法解析org.apache.maven.plugins:maven-resources-plugin:2.4.3
一、发现问题
建立maven项目后,pom.xml在显示红叉,鼠标放上去,显示Execution default-testResources of goal org.apache.maven.plugins:maven-resources-plugin:2.4.3错误。
二、原因分析
缺少maven-resources-plugin-2.4.3.jar或该文件下载不正确,可到repository\org\apache\maven\plugins\maven-resources-plugin\目录看看下载是否正确。或删除该文件重新下载。
三、解决办法
pom.xml文件加入
&dependency&
&groupId&org.apache.maven.plugins&/groupId&
&artifactId&maven-resources-plugin&/artifactId&
&version&2.4.3&/version&
&/dependency&
步骤二:run as —& maven install下载即可
以上是云栖社区小编为您精心准备的的内容,在云栖社区的博客、问答、公众号、人物、课程等栏目也有的相关内容,欢迎继续使用右上角搜索按钮进行搜索文件
解决方法任务、法师战役 解决方法、wow解决方法、wow解决方法任务、解决方法 英文,以便于您获取更多的相关知识。
稳定可靠、可弹性伸缩的在线数据库服务,全球最受欢迎的开源数据库之一
6款热门基础云产品6个月免费体验;2款产品1年体验;1款产品2年体验
弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率
开发者常用软件,超百款实用软件一站式提供
云栖社区()为您免费提供相关信息,包括
,所有相关内容均不代表云栖社区的意见!博客分类:
随着Spring 4新版本的发布,Spring Boot这个新的子项目得到了广泛的关注,因为不管是Spring 4官方发布的新闻稿还是针对首席架构师Adrian Colyer的专访,都对这个子项目所带来的生产率提升赞誉有加。
Spring Boot充分利用了JavaConfig的配置模式以及“约定优于配置”的理念,能够极大的简化基于Spring MVC的Web应用和REST服务开发。
Spring 4倡导微服务的架构,针对这一理念,近来在微博上也有一些有价值的讨论,如这里和这里。微服务架构倡导将功能拆分到离散的服务中,独立地进行部署,Spring Boot能够很方便地将应用打包成独立可运行的JAR包,因此在开发模式上很契合这一理念。目前,Spring Boot依然是0.5.0的里程碑版本,因此相关的文档尚不完善,本文将会以一个简单的样例来介绍基于这个项目的开发过程。
要Spring Boot进行功能开发,需要使用Gradle或者Maven作为构建工具。在本例中,我们会使用Eclipse和Maven插件进行开发。要使用Spring Boot,首先创建一个Maven工程,并修改Maven主要的配置文件pom.xml,如下所示:
&properties&
&java.version&1.7&/java.version&
&start-class&com.test.springboot.Startup&/start-class&
&/properties&
&!-- Inherit defaults from Spring Boot --&
&groupId&org.springframework.boot&/groupId&
&artifactId&spring-boot-starter-parent&/artifactId&
&version&1.0.1.RELEASE&/version&
&!-- Add typical dependencies for a web application --&
&dependencies&
&dependency&
&groupId&org.springframework.boot&/groupId&
&artifactId&spring-boot-starter-web&/artifactId&
&/dependency&
&/dependencies&
&pluginManagement&
&artifactId&maven-compiler-plugin&/artifactId&
&configuration&
&source&1.7&/source&
&target&1.7&/target&
&/configuration&
&/plugins&
&/pluginManagement&
&repositories&
&repository&
&id&spring-snapshots&/id&
&url&http://repo.spring.io/snapshot&/url&
&snapshots&
&enabled&true&/enabled&
&/snapshots&
&/repository&
&repository&
&id&spring-milestones&/id&
&url&http://repo.spring.io/milestone&/url&
&/repository&
&/repositories&
&pluginRepositories&
&pluginRepository&
&id&spring-snapshots&/id&
&url&http://repo.spring.io/snapshot&/url&
&/pluginRepository&
&pluginRepository&
&id&spring-milestones&/id&
&url&http://repo.spring.io/milestone&/url&
&/pluginRepository&
&/pluginRepositories&
在上面的配置中,需要将工程的parent设置为spring-boot-starter-parent,并添加对spring-boot-starter-web的依赖,这样我们就无需设置各个依赖项及其版本信息了。并且在构建中要声明使用spring-boot-maven-plugin这个插件,它会对Maven打包形成的JAR进行二次修改,最终产生符合我们要求的内容结构。
在我们的应用中将要发布一个REST服务,显示一个基本的用户信息,首先定义一个简单的模型类:
public class User {
public Long getId() {
public void setId(Long id) {
public String getName() {
public void setName(String name) {
this.name =
接下来,我们需要声明一个Spring MVC的Controller,响应对实体的请求:
//@EnableAutoConfiguration
@RestController
@RequestMapping("/user")
public class UserController {
@RequestMapping("/{id}")
public User view(@PathVariable("id") Long id) {
User user = new User();
user.setId(id);
user.setName("zhang");
//public static void main(String[] args) {
SpringApplication.run(UserController.class);
这个类与我们在使用Spring MVC定义Controller时并无任何差别。接下来,我们需要声明一个主类启动这个应用程序:
@Configuration
@ComponentScan
@EnableAutoConfiguration
public class Startup {
public static void main(String[] args) {
SpringApplication app = new SpringApplication(Startup.class);
app.setWebEnvironment(true);
app.setShowBanner(false);
Set&Object& set = new HashSet&Object&();
//set.add("classpath:applicationContext.xml");
app.setSources(set);
app.run(args);
这个类的main方法中使用了SpringApplication帮助类,并以Application这个类作为配置来启动Spring的应用上下文。在这个类中使用了ComponentScan以及EnableAutoConfiguration注解,其中ComponentScan注解会告知Spring扫描指定的包来初始化Spring Bean,这能够确保我们声明的Bean能够被发现。EnableAutoConfiguration将会启动自动配置模式,在我们的配置中会将对Tomcat的依赖级联进来,因此在应用启动时将会自动启动一个嵌入式的Tomcat,因为在样例中使用了Spring MVC,所以也会自动注册所需的DispatcherServlet,这都不需要类似web.xml这样的配置。在Eclipse中要运行这个应用的话,可以直接以Java Application的形式来运行这个main函数,此时会启动应用,我们在浏览器中可以看到如下的运行效果,这就是我们想要的REST服务:
在开发调试完成之后,可以将应用打成JAR包的形式,在Eclipse中可以直接使用Maven插件的package命令,最终会形成一个可运行的JAR包。我们使用java –jar命令就可以运行这个JAR包了。Myeclipse的Maven的package请参考( )所呈现出的效果与在调试期是一样的。现在看一下这个JAR包解压后的目录结构:
这个JAR包与传统JAR包的不同之处在于里面有一个名为lib的目录,在这个目录中包含了这个简单应用所依赖的其他JAR包,其中也包含内置的嵌入式Tomcat,正是使用它,才能发布服务和访问Web资源。除了我们编写的源码所编译形成的CLASS以外,在org目录下还有许多Spring所提供的CLASS,正是依赖这些CLASS,才能够加载位于lib目录下JAR中的类。这样的加载机制与在OSGi bundle中声明Bundle-Classpath很类似,不过在OSGi中会由容器来负责加载指定路径下的类。这大致阐述了这样一个JAR包能够发布服务的原因。
如果我们想要使用HTML、JSP等Web资源的话,在Controller中直接返回对应的视图就可以了。
如果我们想要将这个JAR包转换成可以在Servlet容器中部署的WAR的话,就不能依赖于Application的main函数了,而是要以类似于web.xml文件配置的方式来启动Spring应用上下文,此时我们需要声明这样一个类:
public class HelloWebXml extends SpringBootServletInitializer {
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(Application.class);
这个类的作用与在web.xml中配置负责初始化Spring应用上下文的监听器作用类似,只不过在这里不需要编写额外的XML文件了。
如果要将最终的打包形式改为WAR的话,还需要对pom.xml文件进行修改,除了需要将packaging的值修改为war以外,还需要对依赖进行适当的配置(这一部分在Spring Boot的样例和文档中均未提及,提醒大家注意):
&dependency&
&groupId&org.springframework.boot&/groupId&
&artifactId&spring-boot-starter-web&/artifactId&
&exclusions&
&exclusion&
&groupId&org.springframework.boot&/groupId&
&artifactId&spring-boot-starter-tomcat&/artifactId&
&/exclusion&
&/exclusions&
&/dependency&
在这里需要移除对嵌入式Tomcat的依赖,这样打出的WAR包中,在lib目录下才不会包含Tomcat相关的JAR包,否则将会出现启动错误。另外,在移除对Tomcat的依赖后,为了保证编译正确,还需要添加对servlet-api的依赖,因此添加如下的配置:
&dependency&
&groupId&org.apache.tomcat&/groupId&
&artifactId&tomcat-servlet-api&/artifactId&
&version&7.0.42&/version&
&scope&provided&/scope&
&/dependency&
在这里将scope属性设置为provided,这样在最终形成的WAR中不会包含这个JAR包,因为Tomcat或Jetty等服务器在运行时将会提供相关的API类。此时,执行mvn package命令就会得到一个WAR文件,我们可以直接将其放到Tomcat下运行(需要7.0.42版本以上)。
以上介绍了基于Spring Boot开发应用的过程,目前它的文档尚不完善,但是在GitHub上有不少的样例,包括与Spring Data集成访问数据库(关系型以及非关系型)、安全、WebSocket等,读者感兴趣可以下载运行。
基于以上的介绍,希望读者能够对Spring Boot这个新项目有所了解。它简化了JAR包管理和相关基础设施环境的配置,能够帮助我们快速开发Web应用或构建REST服务,希望它能够尽快完善成熟,更多地用于实践,提升开发效率。
浏览 66127
浏览: 278499 次
来自: 北京
&artifactId&maven-compile ...
说明下&start-class&com.test. ...
学习了,感谢了
执行mvn clean install spring-boot ...
请问,filter.c是做什么模块?作用是什么?我的解压出来是 ...step6-----&往工程中添加spring boot项目-------&修改pom.xml使得我的project是基于spring boot的,而非直接基于spring framework - LXRM-JavaWeb、ML - 博客园
文章内容概述:
  spring项目组其实有多个projects,如spring IO platform用于管理external dependencies的版本,通过定义BOM(bill of materials)来管理所引入的external dependencies的版本,从而避免版本冲突问题,再如spring web flow项目,专门为构建流形式的web application提供支持。除了刚刚所叙述的这两个project之外,spring社区还有若干其他project,分别可应用于不同application的开发。Spring协会的这些project都是基于spring framework来创建的,所以支持spring框架的特色功能。同时,它们又对spring framework的modules以及项目可能依赖的三方库、插件等做了基本的封装,在这些project的基础上进行自己的项目的开发,会比直接基于spring framework创建自己的project更便捷。
  我们想要搭建的机器学习管理平台是用于提供restful web services,综合考虑spring社区各个projects的特点,决定舍弃原来的决定,由直接基于the spring framework搭建自己的web网站改为基于spring boot来搭建自己的网站,希望由此简化整个开发过程。
具体操作:
  step1,了解spring boot的特点,参见官网
  step2,&参照 &&&以及&&向项目中引入spring boot
        step2.1 修改pom.xml,包括
              注释掉之前引入的spring framework的modules相关的配置,以及
              添加spring boot相关的配置
            项目最终的pom.xml如下
&project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"&
&modelVersion&4.0.0&/modelVersion&
&groupId&bupt.jinmensuyin.webapp&/groupId&
&artifactId&leapmotion-web&/artifactId&
&packaging&war&/packaging&
&version&0.0.1&/version&
&name&leapmotion-web Maven Webapp&/name&
&!--spring boot中定义了pom.xml,
该pom.xml中引入了spring framework的若干 modules如spring-core、spring-context等,
还引入了三方插件如spring-boot-maven-plugin等
还引入了spring framework的external dependencies...
所以将spring-boot-starter-parent这个pom.xml作为自己的project的parent POM
这样一来,就可以简化自己项目的pom.xml的配置--&
&groupId&org.springframework.boot&/groupId&
&artifactId&spring-boot-starter-parent&/artifactId&
&version&1.4.2.RELEASE&/version&
&dependencies&
&!-- 引入spring-boot中的若干模块作为自己的项目的external dependencies --&
&dependency&
&groupId&org.springframework.boot&/groupId&
&artifactId&spring-boot-starter-web&/artifactId&
&/dependency&
&dependency&
&groupId&org.springframework.boot&/groupId&
&artifactId&spring-boot-starter-test&/artifactId&
&scope&test&/scope&
&/dependency&
&!-- 使用Jackson JSON library完成自己工程中编写的POJO类向JSON字符串的自动转化
如下面步骤中,可以将Greeting类实例自动转化成JSON字符串(其实就是自动将该POJO类对象的属性串成JSON格式的字符串)
&dependency&
&groupId&com.jayway.jsonpath&/groupId&
&artifactId&json-path&/artifactId&
&scope&test&/scope&
&/dependency&
&!-- 单元测试相关的lib,提供用于单元测试的相关API
用于白盒测试,即程序员知道被测试的软件如何(How)完成功能和完成什么样(What)的功能的情况下编写的测试代码
根据Junit所定义的规则进行编写相关测试代码(如测试代码必须继承特定的类等等),可以实现“自动测试”
对不同性质的被测对象,如Class,Jsp,Servlet,Ejb等,Junit有不同的使用技巧--&
&dependency&
&groupId&junit&/groupId&
&artifactId&junit&/artifactId&
&scope&test&/scope&
&/dependency&
&!--<span style="color: #161221:lxrm
修改:将下面的这些external dependencies注释掉
注释原因:研究了Spring协会旗下的所有projects之后,决定在spring boot这个project的基础上搭建自己的网站,
而不是直接依赖于spring framework来开发自己的网站,以期能够减少工作量,加快网站搭建进程 ,
所以将下面的external dependencies注释掉,改为引进spring boot
&dependency&
&groupId&org.springframework&/groupId&
&artifactId&spring-core&/artifactId&
&/dependency&
&dependency&
&groupId&org.springframework&/groupId&
&artifactId&spring-beans&/artifactId&
&/dependency&
&dependency&
&groupId&org.springframework&/groupId&
&artifactId&spring-aop&/artifactId&
&/dependency&
&dependency&
&groupId&org.springframework&/groupId&
&artifactId&spring-aspects&/artifactId&
&/dependency&
&dependency&
&groupId&org.springframework&/groupId&
&artifactId&spring-expression&/artifactId&
&/dependency&
&dependency&
&groupId&org.springframework&/groupId&
&artifactId&spring-orm&/artifactId&
&/dependency&
&/dependencies&
&finalName&leapmotion-web&/finalName&
&!-- 注释原因:没注释之前,报错,错误原因是parent pom中已经指定过一次该插件,将此处配置注释掉以后不再报错
spring-boot-maven-plugin的功能有很多,具体包括:
It collects all the jars on the classpath and builds a single, runnable "über-jar",
which makes it more convenient to execute and transport your service.
It searches for the public static void main() method to flag as a runnable class.
It provides a built-in dependency resolver that sets the version number
to match Spring Boot dependencies. You can override any version you wish,
but it will default to Boot’s chosen set of versions.
&groupId&org.springframework.boot&/groupId&
&artifactId&spring-boot-maven-plugin&/artifactId&
&/plugins&
&dependencyManagement&
&dependencies&
&!-- BOM:bill of materials,是一个external dependency的列表,该列表中确定了各个external dependency的版本
并且保证各个dependencies之间不会出现版本冲突问题 --&
&dependency&
&groupId&io.spring.platform&/groupId&
&artifactId&platform-bom&/artifactId&
&version&Athens-SR1&/version&
&type&pom&/type&
&scope&import&/scope&
&/dependency&
&/dependencies&
&/dependencyManagement&
&repositories&
&repository&
&id&spring-releases&/id&
&url&https://repo.spring.io/libs-release&/url&
&/repository&
&/repositories&
&pluginRepositories&
&pluginRepository&
&id&spring-releases&/id&
&url&https://repo.spring.io/libs-release&/url&
&/pluginRepository&
&/pluginRepositories&
&/project&
        
  step3,编写java程序,测试spring boot是否成功引入
参考教程:
  1)spring
  2)spring官网
  3)博客:
  Greeting.java &POJO类(domain/Model层)
  GreetingController.java &(Controller层,有@RequestMapping之类的标注。In Spring’s approach to building RESTful web services, HTTP requests are handled by a controller. These components are easily identified by the&&annotation, and the&GreetingController&below handles&GET&requests for&/greeting&by returning a new instance of the&Greeting&class:)
& & & GreetingConfiguration.java (相当于配置文件 )
& & & GreetingInitializer.java(相当于配置文件:web.xml中所有与spring(springMVC)相关的配置)
* @author lxrm
* @description:spring boot的入门程序:hello world程序
* @function:这个类是一个POJO类,属于Model层的对象
public class Greeting {
private final long
private final S
public Greeting(long id,String content){
this.content=
public long getId(){
return this.
public Stirng getContent(){
return this.
* @author:lxrm
* @description:spring-boot使用实例: hello world程序
* @function:本程序作为Controller,接收请求,调用相关业务层组件来完成处理任务,并返回处理结果
In Spring’s approach to building RESTful web services,
HTTP requests are handled by a controller.
These components are easily identified by the @RestController annotation,
and the GreetingController below handles GET requests for /greeting
by returning a new instance of the Greeting class:*/
import java.util.concurrent.atomic.AtomicL
import org.springframework.web.bind.annotation.RequestM
import org.springframework.web.bind.annotation.RequestP
import org.springframework.web.bind.annotation.RestC
@RestController
public class GreetingController {
private satic final String template="Hello,%s!";
private final AtomicLong counter=new AtomicLong();
/**About @RequestMapping annotation
1.The @RequestMapping annotation ensures that HTTP requests to
/greeting are mapped to the greeting() method.
2.The above example does not specify GET vs. PUT, POST,
and so forth, because @RequestMapping maps all HTTP operations by default.
Use @RequestMapping(method=GET) to narrow this mapping.
**About @RequestParam annotation
1.@RequestParam 将请求中的参数name绑定到greeting()方法的参数name上.
This query string parameter is explicitly marked as optional (required=true by default):
if it is absent in the request, the defaultValue of "World" is used.*/
@RequestMapping("/greeting")
public Greeting greeting(@RequestParam(value="name", defaultValue="LXRM") String name) {
* @return:创建一个Greeting对象并作为返回值返回
return new Greeting(counter.incrementAndGet(),
String.format(template, name));
* @author lxrm
* @description:spring boot的入门程序:hello world程序
* @function:1)这个类使用@SpringBootApplication注解以及其子注解标签来使得your project中所添加的所有spring注解生效,
有了@SpringBootApplication注解以及其子注解标签(@Configuration、@EnableAutoConfiguration、@EnableWebMvc
@ComponentScan),
就可以不用使用*.xml配置文件,从而使得 there wasn’t a single line of XML? No web.xml file either.
最终整个web application is 100% pure Java
2)这个类中添加了public static void main(String[] args)函数,这就使得整个project可以被打包成可执行的jar包,
该jar包中包含所有necessary dependencies, classes, and resources,可以被直接运行
import org.springframework.boot.SpringA
import org.springframework.boot.autoconfigure.SpringBootA
import org.springframework.ponentS
import org.springframework.context.annotation.C
import org.springframework.web.servlet.config.annotation.EnableWebM
* About @SpringBootApplication 注解
@SpringBootApplication is a convenience annotation that adds all of the following:
@Configuration tags the class as a source of bean definitions for the application context.
@EnableAutoConfiguration tells Spring Boot to start adding beans based on classpath settings,
other beans, and various property settings.
@EnableWebMvc Normally you would add this annotion for a Spring MVC app,
but Spring Boot adds it automatically when it sees spring-webmvc on the classpath.
This flags the application as a web application and activates key behaviors
such as setting up a DispatcherServlet.
@ComponentScan(basePackage="包名") tells Spring to look for other components, configurations,
and services in the the hello package, allowing it to find the controllers.
@Configuration
@EnableWebMvc
@ComponentScan(basePackages = "hello")
public class GreetingConfiguration {
* The main() method uses Spring Boot’s SpringApplication.run() method
* to launch an application. */
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
* @author lxrm
* @description spring boot框架下的第一个程序:helloWorld程序
* @function 1.替代在web.xml中定义的任何spring相关的配置
2.这个类的功能类似于web.xml配置文件的功能,传统web application 中是通过在web.xml中添加相应的配置
如web.xml配置与springMVC相关的DispacthServlet来拦截客户端传来的HTTP请求,并交由spring的controller类处理相关请求,
如配置spring注解相关的类,你的project中添加的与spring框架相关的注解才能被识别
3.spring 4版本中舍弃了*.xml配置文件,直接使用java程序来进行这些配置
XxxConfiguration类使得spring注解生效
XxxInitializer.java(本程序)使得XxxConfiguration类生效,并且配置web.xml中所配置的其他东西*/
import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletI
public class GreetingInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {
protected Class&?&[] getRootConfigClasses() {
return new Class[] { GreetingConfiguration.class };
protected Class&?&[] getServletConfigClasses() {
return null;
protected String[] getServletMappings() {
return new String[] { "/" };
             
随笔 - 178

我要回帖

更多关于 eclipse的pom.xml文件 的文章

 

随机推荐