这是“随着JAVA错误的转变”的下一部分。
所以我有这个应用程序,它编译得很好。我在这里阅读了一个帖子,并将我的app-context.xml和application-context.xml移到了主目录下的SOURCES文件夹中,而不是在Web-Inf /目录中。
我收到此错误:
[ Thread-22] ContextLoader ERROR Context initialization failed
org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [app-context.xml]; nested exception is java.io.FileNotFoun
dException: class path resource [app-context.xml] cannot be opened because it does not exist
这是我的WEB.XML文件部分:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/servlet-context.xml classpath:app-context.xml</param-value>
</context-param>
<context-param>
<param-name>applicationContextLocation</param-name>
<param-value>/WEB-INF/source/applicationContext.xml classpath:applicationContext.xml</param-value>
</context-param>
这是唯一的错误,应用程序无法在Apache Tomcat 7.x中启动。有智慧的想法或话语吗?请?
更新<!/强>
[Thread-18] ContextLoader ERROR Context initialization failed
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 14 in XML document from ServletContext resource [/source/app-context.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 14; columnNumber: 63; The prefix "context" for element "context:component-scan" is not bound.
这是app-context.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:p="http://www.springframework.org/schema/p"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
http://www.springframework.org/schema/context/spring-context-3.0.xsd"
default-autowire="byName">
<tx:annotation-driven classpath="/Web Pages/" />
<!-- Scans within the base package of the application for @Components to
configure as beans -->
<context:component-scan base-package="com.ccur.mdimgmtsys" />
<!-- Drives transactions using local JPA APIs -->
<bean id="transactionManager"
class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean">
<property name="persistenceUnitName" value="forceDatabase" />
</bean>
<bean
class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPost
Processor" />
<bean id="forceService" class="com.force.sdk.connector.ForceServiceConnector">
<property name="connectionName" value="forceDatabase"/>
</bean>
<!--bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"
p:location="/WEB-INF/jdbc.properties" />
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource"
p:driverClassName="${jdbc.driverClassName}"
p:url="${jdbc.url}"
p:username="${jdbc.username}"
p:password="${jdbc.password}" /-->
<!-- ADD PERSISTENCE SUPPORT HERE (jpa, hibernate, etc) -->
</beans>
谢谢,
彼得
答案 0 :(得分:0)
包含上下文命名空间(来自私有项目的示例):
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.2.xsd">
(注意:xmlns:context =“...”以及之后xsi:schemaLocation =“... http://www.springframework.org/schema/context/spring-context-3.2.xsd”
我既没有检查你的弹簧版本也没有检查过最新版本,但不久前这个版本对我有用;) 请将其更新为您所需的版本。