我最近在Eclipse for Web Developers中创建了一个用于教育目的的小型Spring REST项目,版本:Oxygen 3.a Release。 在设置了一些基础知识之后,我想在http://localhost:8080/spring-rest-demo/test/hello上使用我的独立Tomcat 9.0.8服务器运行这个项目,我遇到了一个令人沮丧的错误:
Window with an error 以下日志:
PLATFORM VERSION INFO Windows : 6.1.7601.65536 (Win32NT) Common Language Runtime : 4.0.30319.42000 System.Deployment.dll : 4.6.1055.0 built by: NETFXREL2 clr.dll : 4.6.1055.0 built by: NETFXREL2 dfdll.dll : 4.6.1055.0 built by: NETFXREL2 dfshim.dll : 4.0.41209.0 (Main.041209-0000) SOURCES Deployment url : http://localhost:8080/spring-rest-demo/test/hello ERROR SUMMARY Below is a summary of the errors, details of these errors are listed later in the log. * Activation of http://localhost:8080/spring-rest-demo/test/hello resulted in exception. Following failure messages were detected: + Exception reading manifest from http://localhost:8080/spring-rest-demo/test/hello: the manifest may not be valid or the file could not be opened. + Data at the root level is invalid. Line 1, position 1. COMPONENT STORE TRANSACTION FAILURE SUMMARY No transaction error was detected. WARNINGS There were no warnings during this operation. OPERATION PROGRESS STATUS * [5/6/18 4:38:13 PM] : Activation of http://localhost:8080/spring-rest-demo/test/hello has started. ERROR DETAILS Following errors were detected during this operation. * [5/6/18 4:38:13 PM] System.Deployment.Application.InvalidDeploymentException (ManifestParse) - Exception reading manifest from http://localhost:8080/spring-rest-demo/test/hello: the manifest may not be valid or the file could not be opened. - Source: System.Deployment - Stack trace: at System.Deployment.Application.ManifestReader.FromDocument(String localPath, ManifestType manifestType, Uri sourceUri) at System.Deployment.Application.DownloadManager.DownloadDeploymentManifestDirectBypass(SubscriptionStore subStore, Uri& sourceUri, TempFile& tempFile, SubscriptionState& subState, IDownloadNotification notification, DownloadOptions options, ServerInformation& serverInformation) at System.Deployment.Application.DownloadManager.DownloadDeploymentManifestBypass(SubscriptionStore subStore, Uri& sourceUri, TempFile& tempFile, SubscriptionState& subState, IDownloadNotification notification, DownloadOptions options) at System.Deployment.Application.ApplicationActivator.PerformDeploymentActivation(Uri activationUri, Boolean isShortcut, String textualSubId, String deploymentProviderUrlFromExtension, BrowserSettings browserSettings, String& errorPageUrl) at System.Deployment.Application.ApplicationActivator.ActivateDeploymentWorker(Object state) --- Inner Exception --- System.Xml.XmlException - Data at the root level is invalid. Line 1, position 1. - Source: System.Xml - Stack trace: at System.Xml.XmlTextReaderImpl.Throw(Exception e) at System.Xml.XmlTextReaderImpl.ParseRootLevelWhitespace() at System.Xml.XmlTextReaderImpl.ParseDocumentContent() at System.Deployment.Application.ManifestValidatingReader.XmlFilteredReader.Read() at System.Xml.XsdValidatingReader.Read() at System.Deployment.Application.ManifestReader.FromDocument(String localPath, ManifestType manifestType, Uri sourceUri) COMPONENT STORE TRANSACTION DETAILS No transaction information is available.
我的所有代码都在下面提供:
public class MySpringMvcDispatcherServletInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {
@Override
protected Class<?>[] getRootConfigClasses() {
return null;
}
@Override
protected Class<?>[] getServletConfigClasses() {
return new Class[] { DemoAppConfig.class };
}
@Override
protected String[] getServletMappings() {
return new String[] { "/" };
}
}
@Configuration
@EnableWebMvc
@ComponentScan("com.luv2code.springdemo")
public class DemoAppConfig {}
@RestController
@RequestMapping("/test")
public class DemoRestController {
@GetMapping("/hello")
public String sayHello() {
return "Hello World!";
}
}
我在网上看到了这个错误,但这些解决方案都没有帮助,所以我决定在这里问一下。 试图解决这个问题我已经重新安装了我的Tomcat服务器,并在项目中更新了Maven。它没有帮助。
此外,我不确定它是否相关,但最近我删除了Visual Studio 2015 Community Edition,其中包含大量不同的内置工具和库。虽然我没有看到VS和Tomcat之间的任何连接,但在卸载之前我的所有Spring MVC项目都与Tomcat 9运行良好,但它可能已经破坏了一些东西。