Я пытаюсь использовать контекст весны в простом приложении JMH (http://openjdk.java.net/projects/code-tools/jmh/), но при запуске benchmarks.jar, похоже, проблема с чтением документа схемы весны, хотя он работает на местном уровне.Использование Spring Beans в приложении JMH
Это стандартный проект jmh, созданный из базового архетипа maven. Для простоты ради:
package org.sample;
import org.openjdk.jmh.annotations.Benchmark;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class BenchmarkTest {
public BenchmarkTest() {
ApplicationContext context = new ClassPathXmlApplicationContext("springContext.xml");
}
@Benchmark
public void benchmarkSomething() {
// BENCHMARKS
}
public static void main(String [] args) {
BenchmarkTest benchmarkTest = new BenchmarkTest();
benchmarkTest.benchmarkSomething();
}
}
// Весна конфигурации
<?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">
<!-- spring beans -->
</beans>
При работе с основной есть Java -jar цель/benchmarks.jar без ошибок, но после того, как строить JMH убер баночку и работает
Java -jar мишень/benchmarks.jar
Я получаю следующее сообщение об ошибке
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 8 in XML document from class path resource [springContext.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 8; columnNumber: 80; cvc-elt.1: Cannot find the declaration of element 'beans'.
Любые предложения?
Вы можете разархивировать банку и может выглядеть, если springContext.xml там и содержит именно то, что вы определили? –
Да, это в банке – joecoder