【问题标题】:Error while running spring mvc as standalone app using embedded jetty使用嵌入式码头将 spring mvc 作为独立应用程序运行时出错
【发布时间】:2014-04-02 16:57:46
【问题描述】:

我有一个主类来运行 spring mvc 应用程序作为使用码头的独立应用程序。我使用 maven-shade-plugin 生成 jar 文件。

我在运行 jar 文件时看到以下错误

org.eclipse.jetty.servlet.ServletHolder$1: org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 8 in XML document from ServletContext resource [/WEB-INF/mvc-dispatcher-servlet.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 8; columnNumber: 106; cvc-elt.1: Cannot find the declaration of element 'beans'.

我的 mvc-dispacher-servlet.xml 如下所示

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:mvc="http://www.springframework.org/schema/mvc"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd">

任何人都可以帮助我缺少什么

【问题讨论】:

  • 如果您的列表是完整的 XML,那么需要有一个 或
  • 这只是我的 mvc-dispacher-servlet.xml 的一个 sn-p

标签: spring-mvc embedded-jetty maven-assembly-plugin


【解决方案1】:

它通过在 maven-shade-plugin 配置中添加以下内容来工作

<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
    <resource>META-INF/spring.handlers</resource>
</transformer>
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
    <resource>META-INF/spring.schemas</resource>
</transformer>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-10-29
    • 2011-06-24
    • 1970-01-01
    • 2020-12-30
    • 1970-01-01
    • 2019-03-13
    • 2017-05-25
    • 1970-01-01
    相关资源
    最近更新 更多