我刚开始使用spring,我现在正在使用Spring4
一旦将war部署到JCS-SaaS(云)中,我将得到以下错误:
org.springframework.beans.factory.XML.xmlBeanDefinitionStoreException:类路径资源[pepsiservlet-context.XML]的XML文档中的第33行无效;嵌套异常是org.xml.sax.SAXParseException;行号:33;列号:62;CVC-complex-type2.4.a:发现以元素“resources”开头的内容无效。应为“{”http://www.springframework.org/schema/beans“:导入、”http://www.springframework.org/schema/beans“:别名、”http://www.springframework.org/schema/beans“:bean、WC[##其他:”http://www.springframework.org/schema/beans“]、”http://www.springframework.org/schema/beans“:beans}”之一。
原因:org.xml.sax.SAXParseException;行号:33;列号:62;CVC-complex-type2.4.a:发现以元素“resources”开头的内容无效。应为“{”http://www.springframework.org/schema/beans“:导入、”http://www.springframework.org/schema/beans“:别名、”http://www.springframework.org/schema/beans“:bean、WC[##其他:”http://www.springframework.org/schema/beans“]、”http://www.springframework.org/schema/beans“:beans}”之一。
pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.itc</groupId>
<artifactId>pepsiIndIntegration</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>pepsiIndIntegration Maven Webapp</name>
<url>http://maven.apache.org</url>
<properties>
<jdk.version>1.7</jdk.version>
<spring.version>4.1.7.RELEASE</spring.version>
<slf4j.version>1.7.10</slf4j.version>
<log4j.version>1.2.17</log4j.version>
<apache.commons.version>3.4</apache.commons.version>
</properties>
<dependencies>
<!-- JUnit Dependency -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<!-- Spring Dependencies -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.0.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<version>2.2.2</version>
</dependency>
<!-- Logging Dependencies -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>${log4j.version}</version>
</dependency>
<!-- Spring MVC -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<version>2.2.2</version>
</dependency>
<!-- Org Apache Commons -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>${apache.commons.version}</version>
</dependency>
<!-- Oracle Driver Dependency -->
<!-- <dependency> <groupId>oracle</groupId> <artifactId>ojdbc6</artifactId>
<version>1.0</version> <scope>system</scope> <systemPath>${oracle.driver.path}</systemPath>
</dependency> -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
</dependency>
<!-- Dependency for common file upload -->
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.2.2</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>
<!-- <dependency> <groupId>net.sf.ehcache</groupId> <artifactId>ehcache</artifactId>
<version>2.9.1</version> </dependency> -->
</dependencies>
<build>
<finalName>pepsiIndIntegration</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>${jdk.version}</source>
<target>${jdk.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>2.5</version>
</plugin>
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-xjc-plugin</artifactId>
<version>3.1.2</version>
<configuration>
<extensions>
<extension>org.apache.cxf.xjcplugins:cxf-xjc-dv:3.1.2</extension>
</extensions>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>3.1.2</version>
<executions>
<execution>
<goals>
<goal>wsdl2java</goal>
</goals>
<configuration>
<sourceRoot>${basedir}/target/generated-sources/cxf/wsdl2java</sourceRoot>
<!-- <sourceRoot>${basedir}/target/generated-sources/cxf/wsdl2java</sourceRoot> -->
<!-- <defaultOptions> <bindingFiles> <bindingFile>${binding}/binding.xml</bindingFile>
</bindingFiles> </defaultOptions> -->
<wsdlRoot>${wsdls}</wsdlRoot>
<wsdlOptions>
<wsdlOption>
<wsdl>https://someurl:someport/xyz/abc?wsdl</wsdl>
<extraargs>
<extraarg>-client</extraarg>
</extraargs>
</wsdlOption>
</wsdlOptions>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
下面是web.xml
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
<display-name>Archetype Created Web Application</display-name>
<!-- Loading Beans -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:pepsiBeans.xml
</param-value>
</context-param>
<!-- Spring Dispatched Servlet -->
<servlet>
<servlet-name>pepsiServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:pepsiServlet-context.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>pepsiServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:task="http://www.springframework.org/schema/task"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation=" 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
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/task http://www.springframework.org/schema/task/spring-task.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">
<context:component-scan base-package="com.test.pepsi" />
<!-- DispatcherServlet Context: defines this servlet's request-processing
infrastructure -->
<!-- Enables the Spring MVC @Controller programming model -->
<mvc:annotation-driven />
<!-- Enable Annotation based Declarative Transaction Management -->
<tx:annotation-driven proxy-target-class="true"
transaction-manager="transactionManager" />
<!-- Creating TransactionManager Bean, since JDBC we are creating of type
DataSourceTransactionManager -->
<beans:bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<beans:property name="dataSource" ref="dataSource" />
</beans:bean>
<!-- Handles HTTP GET requests for /resources/** by efficiently serving
up static resources in the ${webappRoot}/resources directory -->
<resources mapping="/resources/**" location="/resources/" />
<!-- Initialization for data source -->
<!-- <beans:bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<beans:property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" />
<beans:property name="url"
value="jdbc:oracle:thin@hostname:port:service/sid" />
<beans:property name="username" value="USER_NAME" />
<beans:property name="password" value="PASSWORD" />
</beans:bean> -->
<beans:bean id="messageSource"
class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<beans:property name="basename" value="classpath:ApplicationMessages" />
<beans:property name="defaultEncoding" value="UTF-8" />
</beans:bean>
<task:annotation-driven scheduler="scheduler"
executor="executor" />
<task:scheduler id="scheduler" pool-size="10" />
<task:executor id="executor" pool-size="10" />
<task:scheduled-tasks scheduler="scheduler">
<task:scheduled ref="pepsiIntgService" method="readFile"
cron="${cronstring}" />
</task:scheduled-tasks>
<!-- <bean id="taskExecutor" class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor">
<property name="corePoolSize" value="5" /> <property name="maxPoolSize" value="10"
/> <property name="queueCapacity" value="25" /> </bean> <bean id="taskExecutorExample"
class="TaskExecutorExample"> <constructor-arg ref="taskExecutor" /> </bean> -->
</beans:bean>
我在xml
文件中看到两个问题:
您的结束标记不正确,它应该是:
</beans:beans> (not </beans:bean>)
因此,与pepsiservlet-context.XML
对应的XML文档格式不正确,因此无法解析。
<mvc:resources mapping="/resources/**" location="/resources/" />
在eclipse中编辑applicationContext.xml时,下面的内容 引发错误: 我在谷歌上搜索了错误,有些地方说订单很重要…我尝试在bean中重新排列项,但错误仍然存在。 怎么啦?
需要“{”http://www.springframework.org/schema/beans“:meta,”h ttp://www.springframework.org/schema/beans“:constructor-arg,”http://www.springframework.org/schema/beans“:property,”http://www.springframework
我正在使用eclipse版本:NEON.3发行版(4.6.3)和Tomcat(V8.5)来进行Java(JDK1.8)编程。 我试图解决的问题 下面是web.xml中的代码 错误显示在前面的标记上。 我可以做什么来解决eclipse错误?
我有一个XML文件需要用XSD文件验证,但是当我想用XSD文件验证我XML时却出现了这个错误 CVC-Complex-Type2.4.a:发现以元素“ClientData”开头的内容无效。应为“”之一。行“2”,列“27”。 这是我的XML文件 我不知道是什么问题...你能告诉我是什么问题吗?
我不知道是什么造成了这个错误。 请帮我修正这个错误。 CVC-complex-type2.4.a:发现以元素“init-param”开头的内容无效。“http://java.sun.com/XML/ns/javaee”:模块-名称、“http://java.sun.com/XML/ns/javaee”:描述、“http://java.sun.com/XML/ns/javaee”:显示-名称、“ht
我已经试着解决这个问题好几个小时了。当我运行我的代码时,我得到一个错误,说: cvc复杂类型.2.4.a:发现以“{”之一的元素“bean”开头的内容无效http://www.springframework.org/schema/context“:包括筛选器,”http://www.springframework.org/schema/context应为“:排除筛选器}”。 我已经到处寻找答案,一