Java spring应用程序中出现错误:cvc elt.1:找不到元素';豆子';
运行Spring应用程序时出错。这是我的qtServlet xml文件Java spring应用程序中出现错误:cvc elt.1:找不到元素';豆子';,java,spring,spring-mvc,servlets,Java,Spring,Spring Mvc,Servlets,运行Spring应用程序时出错。这是我的qtServlet 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/sch
<?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"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.2.4.RELEASE.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.2.4.RELEASE.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.4.RELEASE.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.4.RELEASE.xsd">
<mvc:annotation-driven />
<context:component-scan base-package="jp.co.vmt.qt" />
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp" />
</bean>
<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basename" value="messages" />
</bean>
</beans>
我已经在build.gradle文件中声明了这一点
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.bmuschko:gradle-tomcat-plugin:2.0'
}
}
apply plugin: 'eclipse'
eclipse {
classpath {
downloadSources=true
}
}
apply plugin: 'java'
dependencies {
compile 'org.springframework:spring-beans:4.2.4.RELEASE'
compile 'org.springframework:spring-context:4.2.4.RELEASE'
compile 'org.springframework:spring-core:4.2.4.RELEASE'
// compile 'org.springframework:spring:2.5.6'
compile 'org.springframework:spring-web:4.2.4.RELEASE'
compile 'org.springframework:spring-webmvc:4.2.4.RELEASE'
compile 'org.hibernate:hibernate-core:4.3.6.Final'
// compile 'javax.servlet:javax.servlet-api:3.1.0'
compile 'org.slf4j:slf4j-simple:1.7.7'
compile 'org.javassist:javassist:3.15.0-GA'
compile 'mysql:mysql-connector-java:5.1.31'
compile 'commons-dbcp:commons-dbcp:1.4'
compile 'org.springframework.data:spring-data-jpa:1.9.2.RELEASE'
compile 'org.springframework:spring-jdbc:4.2.4.RELEASE'
compile 'org.springframework:spring-orm:4.2.4.RELEASE'
}
apply plugin: 'war'
apply plugin: 'com.bmuschko.tomcat'
// JDK version source compatibility
sourceCompatibility = 1.7
// project version
version = '1.0'
// War file name
war.baseName = 'WebGradle'
// Web directory, this overrides the default value "webapp"
project.webAppDirName = 'WebContent'
repositories {
mavenLocal()
mavenCentral()
}
// Set source directory
sourceSets {
main {
java {
srcDir 'src'
}
}
}
// dependencies to run on tomcat, are mandatory for tomcat plugin
dependencies {
def tomcatVersion = '7.0.57'
tomcat "org.apache.tomcat.embed:tomcat-embed-core:${tomcatVersion}",
"org.apache.tomcat.embed:tomcat-embed-logging-juli:${tomcatVersion}"
tomcat("org.apache.tomcat.embed:tomcat-embed-jasper:${tomcatVersion}") {
exclude group: 'org.eclipse.jdt.core.compiler', module: 'ecj'
}
}
// context where tomcat is deployed, by defautl localhost:8080/
tomcatRun.contextPath = '/'
tomcatRunWar.contextPath = '/'
我认为我在qtServlet-servlet.xml和build.gradle中正确地声明了正确的依赖项和版本,但我得到了上述错误。我已经验证了jar文件在我的构建路径和tomcat的部署路径中。我不确定是什么导致了这个错误,因为类似的问题表明XSD的版本与Dependencies中声明的版本不正确。有什么帮助吗?谢谢。从架构位置删除版本信息 试试这个:
xsi:schemaLocation="http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd"
谢谢,当我试图用浏览器访问模式位置时,我发现它们不存在,所以我将其更改为存在的版本。
xsi:schemaLocation="http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd"