tôi có thể biên dịch và bắt đầu dự án Spring tôi sử dụng Maven:ngoại lệ áp dụng bắt đầu từ mùa xuân từ Java
mvn -e clean compile exec:java -Dexec.mainClass=de.fraunhofer.fkie.tet.vmware.manager.Test
Tuy nhiên, khi tôi lắp ráp tất cả các lọ trong một tập tin duy nhất sử dụng maven-assembly-plugin
(bao gồm applicationContext.xml
), tôi luôn nhận được một Exception
trong quá trình thực java
:
java -cp target/test-jar-with-dependencies.jar:. de.fraunhofer.fkie.tet.vmware.manager.Test
INFO: Loading XML bean definitions from class path resource [applicationContext.xml]
Sep 6, 2010 10:37:21 AM org.springframework.util.xml.SimpleSaxErrorHandler warning
WARNING: Ignored XML validation warning
org.xml.sax.SAXParseException: schema_reference.4: Failed to read schema document 'http://www.springframework.org/schema/context/spring-context.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>.
...
Exception in thread "main" org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException:
Line 10 in XML document from class path resource [applicationContext.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cvc-complex-type.2.4.c:
The matching wildcard is strict, but no declaration can be found for element 'context:annotation-config'.
...
Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.4.c:
The matching wildcard is strict, but no declaration can be found for element 'context:annotation-config'.
tôi cũng đã cố gắng để đính kèm các định nghĩa lược đồ, tức là spring-context.xsd
vv trực tiếp vào classpath, nhưng không có bất kỳ thành công.
less src/main/resources/applicationContext.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/schema/context"
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">
<context:annotation-config /> <!-- wegen '@PostConstruct' -->
<!--<context:component-scan base-package="de.fraunhofer" /> -->
...
</beans>
Bạn có thể đăng ứng dụng của mìnhContext.xml - hoặc ít nhất là phần tiêu đề. Tôi nghi ngờ rằng có vấn đề với tiêu đề của bạn/tham chiếu dtd, v.v. –
'applicationContext.xml' được đăng ở trên. Thật ngạc nhiên, ứng dụng chạy mà không có bất kỳ vấn đề gì, nếu 'mvn exec: java' được sử dụng để khởi động nó. – rmv