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
最满意答案
程序在运行时搜索并加载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.zip
或curl-7.34.0-win64.zip
,具体取决于您的目标是win32
还是win64
。 提取存档并分别在子目录lib
和dlls
找到导入库和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.lib
,your\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
islibcurl.lib
. If you have downloaded and extractedcURL
, say, intoC:\develop\curl-7.34.0-win32
, then you will find the import library atC:\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 oflibcurl.dll
in the directory from which your program runs. Otherwise you can decide on a location for it by studying Dynamic-Link Library Search OrderYou 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 eithercurl-7.34.0-win32.zip
orcurl-7.34.0-win64.zip
, depending on whether you are targettingwin32
orwin64
. Extract the archive and find the import library and DLL in the subdirectorieslib
anddlls
, 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 cleanC
project (notC++
).- 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 theinclude\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
withcurl-7.34.0-win32
from the same site. In your project, replaceyour\path\to\curl-7.34.0-win64\lib\libcurl.lib
withyour\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 bylibcurl.dll
in turn. For the purpose of the example just copy all the DLLs fromyour\path\to\curl-7.34.0-win32\dlls
into the same directory as the.exe
. For regular development ofcURL
apps you would want thecURL
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库的程序(使用Codeblocks)?(How to compile a program that need HDF5 library (using Codeblocks)?)[2022-04-30]
编译时需要依赖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 ...
-
将变量导入DLL(Importing variables into a DLL)[2022-05-23]
因此,经过长时间的研究和与工作中的一些人交谈,我们设法放弃了对静态库的需求,因为我认为不可能这样做。 因此,基于上面的示例代码,enginelib成为DLL,头API块变为: #if defined(__ISADLL__) #define API __declspec(dllexport) #else #define API __declspec(dllimport) #endif 并且plugindll和exe都链接到由enginelib dll构建生成的.lib。 So after ... -
使用CodeBlocks编译64位DLL会导致链接器错误(Compiling a 64-bit DLL with CodeBlocks gives linker errors)[2022-07-13]
固定,我是个白痴。 很久以前,我在“编译器和调试器”下的链接器设置中将-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 这使得所有项目链接到这个目录。 如 ...