首页 \ 问答 \ cvc-complex-type.2.4.a:从元素'拦截器'Spring开始发现无效内容(cvc-complex-type.2.4.a: Invalid content was found starting with element 'interceptors' Spring)

cvc-complex-type.2.4.a:从元素'拦截器'Spring开始发现无效内容(cvc-complex-type.2.4.a: Invalid content was found starting with element 'interceptors' Spring)

我检查了几个类似的问题,但没有人能解决我的问题。 我在我的spring xml配置文件中添加了拦截器,它向我抛出上述错误。

我的xml格式如下所示 -

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
....
...

    <mvc:annotation-driven .. />
    <bean id="transactionManager"
        ...
        ...

    </bean>
    <bean id="diffrent id"
        ...
        ...

    </bean>
    <bean id="diffrent id"
        ...
        ...

    </bean>

    // added interceptor below
    <interceptors>
            <mapping path="/*"/>
            <bean class="path of class" ></bean>
    </interceptors>
    <context:component-scan base-package="pacakge path" />
</beans>

你能帮我解决这个问题吗? 提前致谢。


I have checked several similar issues but none could solve my problem. I have added interceptor in my spring xml config file and it is throwing me the above mentioned error.

My xml formation looks like below-

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
....
...

    <mvc:annotation-driven .. />
    <bean id="transactionManager"
        ...
        ...

    </bean>
    <bean id="diffrent id"
        ...
        ...

    </bean>
    <bean id="diffrent id"
        ...
        ...

    </bean>

    // added interceptor below
    <interceptors>
            <mapping path="/*"/>
            <bean class="path of class" ></bean>
    </interceptors>
    <context:component-scan base-package="pacakge path" />
</beans>

Can you please help me on how to resolve this issue. Thanks in advance.


原文:https://stackoverflow.com/questions/32680827
更新时间:2023-08-03 16:08

最满意答案

程序在运行时搜索并加载DLL(动态链接库)。 要自动执行此操作,请不要链接.dll本身(您不能)。 您链接匹配的导入库 ,扩展名为.lib

libcurl.dll的导入库是libcurl.lib 。 如果您已经下载并提取了cURL ,比如说,进入C:\develop\curl-7.34.0-win32 ,那么你会在C:\develop\curl-7.34.0-win32\lib\libcurl.lib找到导入库。 。 您应该将此文件添加到Code :: Blocks项目的库中。

然后项目将链接(除非它有其他问题),但为了使其成功运行,它必须在运行时搜索DLL的位置之一找到libcurl.dll 。 确保这一点的最简单方法是将libcurl.dll的副本放在运行程序的目录中。 否则,您可以通过研究动态链接库搜索顺序来确定它的位置

您可能很难找到合适的二进制包来从这里提供的过多内容中下载。 其中一些是cURL命令行工具的包(您不需要),其中一些是各种平台的开发二进制文件包(您确实需要)。 访问http://www.confusedbycode.com/curl/并下载curl-7.34.0-win32.zipcurl-7.34.0-win64.zip ,具体取决于您的目标是win32还是win64 。 提取存档并分别在子目录libdlls找到导入库和DLL。

更新OP的进一步问题

您的程序是提供的示例simple.c ,并添加了C ++标头<iostream>

  • 删除你的libcurl项目,然后用一个干净的C项目(而不是C++ )重新开始。
  • 仅向C项目添加1个源文件,例如simple.c或其副本。 不要将其作为.cpp文件或以其他方式更改它。 不要将任何其他文件添加到项目中。
  • 构建选项 - > 链接器设置 - > 链接库中 ,像以前一样添加libcurl.lib的相对路径。
  • 构建选项 - > 搜索目录 - > 编译器 (不是链接器 )中,添加cURL include目录的相对路径,不添加任何其他内容(不include\curl目录)。
  • 不要在搜索目录 - > 链接器中放置任何内容。
  • 建立项目。 它为我编译和链接。

更新#2

现在的问题是您尝试将64位curl-7.34.0-win64\lib\libcurl.lib与32位工具链mingw32生成的32位目标代码链接起来。 你不能那样做。

用同一站点的curl-7.34.0-win32替换你的curl-7.34.0-win64安装。 在项目中,将your\path\to\curl-7.34.0-win64\lib\libcurl.lib更换your\path\to\curl-7.34.0-win64\lib\libcurl.libyour\path\to\curl-7.34.0-win32\lib\libcurl.lib然后重试。 该示例将编译和链接。

它也将正常运行,前提是它在运行时找到32位libcurl.dll ,同样依次由libcurl.dll动态加载的32位DLL。 出于示例的目的,只需将your\path\to\curl-7.34.0-win32\dlls所有DLL复制到与.exe相同的目录中。 对于cURL应用程序的常规开发,您需要在系统上安装cURL库。

由于您首先选择下载64位cURL ,因此您可能希望构建64位可执行文件(尽管32位可执行文件将在64位主机上运行)。 你不能用你的32位工具链mingw32 。 您可以安装64位工具链,例如TDM-GCC MinGW编译器 ,并将其配置为C :: B中的附加工具链。 或者,你可以用来自Sourceforge的具有TDM-GCC预配置的C :: B 13.12替换你的C :: B安装


A DLL (dynamic link library) is searched for and loaded by your program at runtime. To make this happen automatically, you do not link the .dll itself (you can't). You link the matching import library, with extension .lib.

The import library for libcurl.dll is libcurl.lib. If you have downloaded and extracted cURL, say, into C:\develop\curl-7.34.0-win32, then you will find the import library at C:\develop\curl-7.34.0-win32\lib\libcurl.lib. You should add this file to the libraries for your Code::Blocks project.

The project will then link (unless it has other problems), but in order for it to run successfully it will have to find libcurl.dll in one of the locations that are searched for DLLs at runtime. The simplest way to ensure this is to place a copy of libcurl.dll in the directory from which your program runs. Otherwise you can decide on a location for it by studying Dynamic-Link Library Search Order

You may have difficulty in finding the right binary package to download from the plethora available here. Some of them are packages of the cURL commandline tools (which you don't want) and some of them are packages of the development binaries (which you do want) for various platforms. Visit http://www.confusedbycode.com/curl/ and download either curl-7.34.0-win32.zip or curl-7.34.0-win64.zip, depending on whether you are targetting win32 or win64. Extract the archive and find the import library and DLL in the subdirectories lib and dlls, respectively.

Update for OP's further issues

Your program is the supplied example simple.c with the addition of a C++ header, <iostream>.

  • Delete your libcurl project and start again with a clean C project (not C++).
  • Add only 1 source file to the C project, the example simple.c or a copy of it. Don't make it a .cpp file or otherwise change it. Don't add any other files to the project.
  • In Build options -> Linker settings -> Link libraries add the relative path to libcurl.lib as you did before.
  • In Build options -> Search Directories -> Compiler (not Linker) add the relative path to the cURL include directory and nothing else (not the include\curl directory).
  • Do not put anything in Search directories -> Linker.
  • Build the project. It compiles and links for me.

Update #2

The problem now is that you are attempting to link the 64-bit curl-7.34.0-win64\lib\libcurl.lib with the 32-bit object code generated by your 32-bit toolchain, mingw32. You can't do that.

Replace your install of curl-7.34.0-win64 with curl-7.34.0-win32 from the same site. In your project, replace your\path\to\curl-7.34.0-win64\lib\libcurl.lib with your\path\to\curl-7.34.0-win32\lib\libcurl.lib and try again. The example will compile and link.

It will also run correctly, provided that it finds 32-bit libcurl.dll at runtime, and likewise the 32-bit DLLs that are dynamically loaded by libcurl.dll in turn. For the purpose of the example just copy all the DLLs from your\path\to\curl-7.34.0-win32\dlls into the same directory as the .exe. For regular development of cURL apps you would want the cURL libraries installed on the the system.

Since you chose to download 64-bit cURL in the first place, you may wish to build 64-bit executables (although 32-bit executables will run on 64-bit hosts). You can't do that that with your 32-bit toolchain, mingw32. You can install a 64-bit toolchain, e.g. TDM-GCC MinGW Compiler, and configure it as an additional toolchain in C::B. Alternatively you could replace your C::B installation with a C::B 13.12 one that has TDM-GCC pre-configured, from Sourceforge

相关问答

更多
  • 构建静态库时,您只需将一堆目标文件放在一个易于发布和使用的实体中。 构建静态库时没有完成链接。 在构建应用程序或某些共享对象时,将处理来自库的未解析引用。 您只需运送您的库,并要求用户在构建时也提供您的库所依赖的库。 如果要包含库中依赖的库, 可以从tgat库中提取目标文件并将其包含在库中。 虽然技术上可行,但如果您有权这样做,则值得怀疑。 此外,这通常不是事情的方式,我建议不要这样做。 When building a static library you are just putting together ...
  • 以下是使用Code :: Blocks设置Boost的说明 Here are the instructions for setting up Boost with Code::Blocks
  • 好吧,所以有一个简单的解决方案,代码:: blocks的项目文件是非常平凡的,轻量级的XML实现 - 你可以通过编辑纯文本,非常容易地将库(按正确的顺序)从一个项目复制到另一个项目。 cbp文件。 Alright, so there's a simple solution, the project file for code::blocks is quite mundane, a light XML implementation- you can very easily copy libraries (in ...
  • 不要将自己构建的文件放在/usr/...除非将它们放在/usr/local/... 。 /usr/...的其余部分由Linux发行版保留,应由程序包管理器专门填充。 如果你在包管理员的背后乱七八糟,你就有可能破坏你的包装并承受任何痛苦。 首先从/usr/lib删除libgtest.a和libgtest_main.a 。 您已经下载了googletest并通过首先在该目录中运行CMake然后运行make其构建在某个目录中。 完成后,在运行make的同一目录中运行: sudo make install 这将在 ...
  • 编译时需要依赖hdf5.mod ,而不是链接时间,这就是为什么你没有通过链接器选项成功修复它。 模块文件在某种程度上在概念上类似于C包含文件(虽然在实现方面非常不同而且不可移植)。 要允许编译器找到它们,可以通过-I选项传递搜索路径。 在代码块中,您应该找到正在处理的链接器选项旁边的search directories选项卡(在项目构建选项中)。 在搜索目录选项卡中,您需要选择编译器选项卡,然后添加hdf5模块文件的路径。 The dependency hdf5.mod is needed at compi ...
  • 程序在运行时搜索并加载DLL(动态链接库)。 要自动执行此操作,请不要链接.dll本身(您不能)。 您链接匹配的导入库 ,扩展名为.lib 。 libcurl.dll的导入库是libcurl.lib 。 如果您已经下载并提取了cURL ,比如说,进入C:\develop\curl-7.34.0-win32 ,那么你会在C:\develop\curl-7.34.0-win32\lib\libcurl.lib找到导入库。 。 您应该将此文件添加到Code :: Blocks项目的库中。 然后项目将链接(除非它有 ...
  • 音频库未链接到。 这就是未定义的引用错误意味着什么。 因此,您应该检查您的项目文件是否链接到路径中存在的静态lib文件( .a )。 另一件事是你不需要你的链接器设置中的任何库,除了SFML库之外,因为它们已经链接到SFML静态lib文件中。 在2.3中不是这样,但在2.1中是正确的 The audio library is not being linked to. That's what an undefined reference error means. So you should probably ...
  • 因此,经过长时间的研究和与工作中的一些人交谈,我们设法放弃了对静态库的需求,因为我认为不可能这样做。 因此,基于上面的示例代码,enginelib成为DLL,头API块变为: #if defined(__ISADLL__) #define API __declspec(dllexport) #else #define API __declspec(dllimport) #endif 并且plugindll和exe都链接到由enginelib dll构建生成的.lib。 So after ...
  • 固定,我是个白痴。 很久以前,我在“编译器和调试器”下的链接器设置中将-m32设置为永久标志。 删除它,现在完美地工作。 Fixed, I'm an idiot. Long ago, I had set -m32 as a permanent flag in the linker settings under "Compiler and debugger." Removed it, works perfectly now.
  • 如果所有头文件都位于一个目录中,则应能够将该目录包含在全局设置中。 每个项目都会在那里寻找文件。 code :: blocks - > settings - > compiler settings - > global compiler settings - > compiler settings tab - > other options tab - > write“-I the / string / to / your / directories”and - > OK 这使得所有项目链接到这个目录。 如 ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)