现有项目的 Spring Batch Process 实现
Posted
技术标签:
【中文标题】现有项目的 Spring Batch Process 实现【英文标题】:Spring Batch Process Implementation on Existing Project 【发布时间】:2016-07-13 02:13:03 【问题描述】:大家好!我正在使用 Angular JS 在 Spring MVC 框架上开发基于业务的项目。现在作为我项目的一部分,需要完成一些繁重的处理,这些处理应该在后台运行,例如文件处理、验证、数据库存储和检索、业务规则处理等。
我也是这些基于网络的技术的新手,所以请帮助我。
为了实现这一点,我从 Spring Batch Process 开始,阅读 下面的教程:
docs.spring.io/spring-batch/reference/html/spring-batch-intro.html (不允许发布超过2个链接这样粘贴)
了解了教程并找到了一些示例,如下所示:
www.javacodegeeks.com/2015/03/spring-batch-tutorial.html (不允许发布超过2个链接这样粘贴)
https://spring.io/guides/gs/batch-processing/
(因为我现有的项目是纯粹基于 Java 的(不基于 XML 配置)所以我相应地搜索并找到了上面的链接 例子。)
现在在浏览这些示例时,无论我看到什么示例 仅给出独立实施,即没有现有项目 我找到了这样的实现,所以我所做的是提取 pom.xml 来自这些示例的配置并与现有的集成 pom.xml 文件。
因此,在此之后,当我从这些示例中在现有项目中添加所需的 springbatch 目录并尝试使用 mvn clean install 运行它时,它开始失败,如下所示:
Spring-boot-maven-plugin repackage goal error using nar-maven-plugin
所以我在互联网上搜索了这个问题并发现结论为 在上面的链接中提到并添加了一个额外的分类器行 我的 pom.xml 发生了变化,所以在那之后它开始正常工作,然后我是 能够生成两个war文件。
所以当我在 WildFly 下部署这些战争时,它开始失败 不断出现非常大的错误。
以下是我的集成 POM 文件(我在原始 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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.business.alysisapp</groupId>
<artifactId>analysisapp</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>Analysis App</name>
<url>http://maven.apache.org</url>
**<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.2.1.RELEASE</version>
</parent>**
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<spring.version>4.0.3.RELEASE</spring.version>
**<start-class>com.Test</start-class>**
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<verbose>false</verbose>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<!-- Web.xml is now configured programmatically in SpringWebAppInitializer.java name -->
<failOnMissingWebXml>false</failOnMissingWebXml>
<outputDirectory>C:\Users\developer\Documents\WildFly\standalone\deployments</outputDirectory>
<!-- WAR name -->
<warName>analysisapp</warName>
</configuration>
</plugin>
**<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<classifier>exec</classifier>
</configuration>
</plugin>**
</plugins>
<finalName>analysisapp</finalName>
</build>
<dependencies>
**<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-batch</artifactId>
</dependency>**
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<!-- Spring Batch unit test -->
**<dependency>
<groupId>org.springframework.batch</groupId>
<artifactId>spring-batch-test</artifactId>
</dependency>**
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hibernate.common</groupId>
<artifactId>hibernate-commons-annotations</artifactId>
<version>5.0.0.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>5.0.2.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-envers</artifactId>
<version>5.0.2.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.1-api</artifactId>
<version>1.0.0.Final</version>
</dependency>
<!-- Servlet API -->
<dependency>
<groupId>org.jboss.spec.javax.servlet</groupId>
<artifactId>jboss-servlet-api_3.1_spec</artifactId>
<version>1.0.0.Final</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.1</version>
<scope>provided</scope>
</dependency>
<!-- Logging dependencies -->
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.1.2</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>1.1.2</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.9</version>
</dependency>
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.20.0-GA</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
<version>1.9.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>4.2.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
<version>4.2.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.7.4</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>4.2.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.2.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>4.2.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.2.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-expression</artifactId>
<version>4.2.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-instrument</artifactId>
<version>4.2.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>4.2.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jms</artifactId>
<version>4.2.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-messaging</artifactId>
<version>4.2.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>4.2.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-oxm</artifactId>
<version>4.2.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>4.2.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>4.2.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>4.2.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>4.2.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc-portlet</artifactId>
<version>4.2.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-websocket</artifactId>
<version>4.2.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
<version>3.0.3.RELEASE</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.5.4</version>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-core-asl</artifactId>
<version>1.9.7</version>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.9.7</version>
</dependency>
<dependency>
<groupId>org.jbpm</groupId>
<artifactId>jbpm-flow</artifactId>
<version>6.1.0.Final</version>
</dependency>
<dependency>
<groupId>org.jbpm</groupId>
<artifactId>jbpm-bpmn2</artifactId>
<version>6.1.0.Final</version>
</dependency>
<dependency>
<groupId>org.jbpm</groupId>
<artifactId>jbpm-flow-builder</artifactId>
<version>6.1.0.Final</version>
</dependency>
<!-- For 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>1.4</version>
</dependency>
<!-- For Amazon S3 service (file upload) -->
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk</artifactId>
<version>1.7.5</version>
</dependency>
<!-- For Drool Rules -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.11</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.11-beta2</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.11-beta2</version>
</dependency>
</dependencies>
</project>
这是我使用的网络示例的 POM 文件 & 在我的实际 POM.xml 文件中添加了这些更改。
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.danibuiza.javacodegeeks</groupId>
<artifactId>Spring-Batch-Tutorial-Annotations</artifactId>
<version>0.1.0</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.2.1.RELEASE</version>
</parent>
<properties>
<start-class>com.Test</start-class>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-batch</artifactId>
</dependency>
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<!-- Spring Batch unit test -->
<dependency>
<groupId>org.springframework.batch</groupId>
<artifactId>spring-batch-test</artifactId>
</dependency>
<!-- Junit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
我通过谷歌搜索了很多关于 *** 和其他可能的选项,但不走运。作为这个 Spring Batch Process 的新手,我真的不知道如何 从这里开始,因为这对我来说是一个障碍,我正在努力争取 5 连续几天。这是一个善意的请求,请告知我该如何进行 我将能够将 Spring Batch Process 与我的 现有的应用程序。这也可能是一个重复的问题,但它 如果有人能指出更好的方向,那就太好了 我可以从那里开始。
运行 Wildfly 后的日志:
2016-03-25 16:16:22,957 INFO [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 2) WFLYDS0010: Scan found incompletely copied file content for deployment C:\Users\developer\Documents\WildFly\standalone\deployments\analysisapp.war. Deployment changes will not be processed until all content is complete.
2016-03-25 16:16:35,617 INFO [org.jboss.as.repository] (DeploymentScanner-threads - 1) WFLYDR0001: Content added at location C:\Users\developer\Documents\WildFly\standalone\data\content\53\45eaa8fbc1f098ffb898ba09eabe4a152de5fa\content
2016-03-25 16:16:35,678 INFO [org.wildfly.extension.undertow] (ServerService Thread Pool -- 131) WFLYUT0022: Unregistered web context: /analysisapp
2016-03-25 16:16:35,682 INFO [io.undertow.servlet] (ServerService Thread Pool -- 131) Destroying Spring FrameworkServlet 'SpringDispatcher'
2016-03-25 16:16:35,684 INFO [org.springframework.web.context.support.AnnotationConfigWebApplicationContext] (ServerService Thread Pool -- 131) Closing Analysis App: startup date [Fri Mar 25 15:48:21 IST 2016]; root of context hierarchy
2016-03-25 16:16:35,698 INFO [org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean] (ServerService Thread Pool -- 131) Closing JPA EntityManagerFactory for persistence unit 'default'
2016-03-25 16:16:35,698 INFO [io.undertow.servlet] (ServerService Thread Pool -- 131) Closing Spring root WebApplicationContext
2016-03-25 16:16:36,093 INFO [org.jboss.as.server.deployment] (MSC service thread 1-4) WFLYSRV0028: Stopped deployment analysisapp.war (runtime-name: analysisapp.war) in 448ms
2016-03-25 16:16:36,117 INFO [org.jboss.as.server.deployment] (MSC service thread 1-2) WFLYSRV0027: Starting deployment of "analysisapp.war" (runtime-name: "analysisapp.war")
2016-03-25 16:16:58,592 WARN [org.jboss.as.ee] (MSC service thread 1-1) WFLYEE0007: Not installing optional component org.springframework.http.server.ServletServerHttpAsyncRequestControl due to an exception (enable DEBUG log level to see the cause)
2016-03-25 16:16:58,597 WARN [org.jboss.as.ee] (MSC service thread 1-1) WFLYEE0007: Not installing optional component org.springframework.web.context.request.async.StandardServletAsyncWebRequest due to an exception (enable DEBUG log level to see the cause)
2016-03-25 16:16:58,698 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-1) WFLYJCA0004: Deploying JDBC-compliant driver class org.hsqldb.jdbc.JDBCDriver (version 2.3)
2016-03-25 16:16:58,718 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-1) WFLYJCA0005: Deploying non-JDBC-compliant driver class com.mysql.jdbc.Driver (version 5.1)
2016-03-25 16:16:58,722 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-1) WFLYJCA0005: Deploying non-JDBC-compliant driver class com.mysql.fabric.jdbc.FabricMySQLDriver (version 5.1)
2016-03-25 16:16:58,722 WARN [org.jboss.weld.deployer] (MSC service thread 1-1) WFLYWELD0013: Deployment deployment "analysisapp.war" contains CDI annotations but no bean archive was not found. (No beans.xml nor class with bean defining annotations)
2016-03-25 16:16:58,738 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-2) WFLYJCA0018: Started Driver service with driver-name = analysisapp.war_com.mysql.jdbc.Driver_5_1
2016-03-25 16:16:58,738 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-3) WFLYJCA0018: Started Driver service with driver-name = analysisapp.war_com.mysql.fabric.jdbc.FabricMySQLDriver_5_1
2016-03-25 16:16:58,738 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-1) WFLYJCA0018: Started Driver service with driver-name = analysisapp.war_org.hsqldb.jdbc.JDBCDriver_2_3
2016-03-25 16:16:58,806 INFO [io.undertow.servlet] (ServerService Thread Pool -- 279) Spring WebApplicationInitializers detected on classpath: [org.springframework.boot.autoconfigure.jersey.JerseyAutoConfiguration@5538eb02, com.bizmerlin.config.SpringWebAppInitializer@5466ddd5]
2016-03-25 16:16:58,838 INFO [javax.enterprise.resource.webcontainer.jsf.config] (ServerService Thread Pool -- 279) Initializing Mojarra 2.2.11-jbossorg-1 20150505-1501 for context '/analysisapp'
2016-03-25 16:17:13,858 INFO [io.undertow.servlet] (ServerService Thread Pool -- 279) Initializing Spring root WebApplicationContext
2016-03-25 16:17:13,858 INFO [org.springframework.web.context.ContextLoader] (ServerService Thread Pool -- 279) Root WebApplicationContext: initialization started
2016-03-25 16:17:13,916 INFO [org.springframework.web.context.support.AnnotationConfigWebApplicationContext] (ServerService Thread Pool -- 279) Refreshing Analysis App: startup date [Fri Mar 25 16:17:13 IST 2016]; root of context hierarchy
2016-03-25 16:17:13,938 INFO [org.springframework.web.context.support.AnnotationConfigWebApplicationContext] (ServerService Thread Pool -- 279) Registering annotated classes: [class com.bizmerlin.config.ApplicationContextConfiguration]
2016-03-25 16:17:13,954 INFO [org.springframework.web.context.support.AnnotationConfigWebApplicationContext] (ServerService Thread Pool -- 279) Scanning base packages: [com.bizmerlin]
2016-03-25 16:17:14,083 ERROR [org.springframework.web.context.ContextLoader] (ServerService Thread Pool -- 279) Context initialization failed: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: VFS resource ["/C:/Users/developer/Documents/WildFly/bin/content/analysisapp.war/WEB-INF/classes/com/bizmerlin/config/EntityManagerFactoryConfiguration.class"]; nested exception is java.lang.annotation.AnnotationFormatError: Invalid default: public abstract java.lang.Class org.springframework.data.jpa.repository.config.EnableJpaRepositories.repositoryBaseClass()
at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.findCandidateComponents(ClassPathScanningCandidateComponentProvider.java:303)
at org.springframework.context.annotation.ClassPathBeanDefinitionScanner.doScan(ClassPathBeanDefinitionScanner.java:248)
at org.springframework.context.annotation.ClassPathBeanDefinitionScanner.scan(ClassPathBeanDefinitionScanner.java:226)
at org.springframework.web.context.support.AnnotationConfigWebApplicationContext.loadBeanDefinitions(AnnotationConfigWebApplicationContext.java:219)
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:129)
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:604)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:509)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:446)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:328)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)
at io.undertow.servlet.core.ApplicationListeners.contextInitialized(ApplicationListeners.java:173)
at io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:195)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:100)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:82)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
at org.jboss.threads.JBossThread.run(JBossThread.java:320)
Caused by: java.lang.annotation.AnnotationFormatError: Invalid default: public abstract java.lang.Class org.springframework.data.jpa.repository.config.EnableJpaRepositories.repositoryBaseClass()
at java.lang.reflect.Method.getDefaultValue(Method.java:611)
at org.springframework.core.type.clas-s-reading.RecursiveAnnotationAttributesVisitor.registerDefaultValues(RecursiveAnnotationAttributesVisitor.java:69)
at org.springframework.core.type.clas-s-reading.RecursiveAnnotationAttributesVisitor.doVisitEnd(RecursiveAnnotationAttributesVisitor.java:57)
at org.springframework.core.type.clas-s-reading.AnnotationAttributesReadingVisitor.doVisitEnd(AnnotationAttributesReadingVisitor.java:67)
at org.springframework.core.type.clas-s-reading.RecursiveAnnotationAttributesVisitor.visitEnd(RecursiveAnnotationAttributesVisitor.java:48)
at org.springframework.asm.ClassReader.readAnnotationValues(ClassReader.java:1802)
at org.springframework.asm.ClassReader.accept(ClassReader.java:642)
at org.springframework.asm.ClassReader.accept(ClassReader.java:508)
at org.springframework.core.type.clas-s-reading.SimpleMetadataReader.<init>(SimpleMetadataReader.java:64)
at org.springframework.core.type.clas-s-reading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:98)
at org.springframework.core.type.clas-s-reading.CachingMetadataReaderFactory.getMetadataReader(CachingMetadataReaderFactory.java:102)
at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.findCandidateComponents(ClassPathScanningCandidateComponentProvider.java:279)
... 19 more
2016-03-25 16:17:14,282 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 279) MSC000001: Failed to start service jboss.undertow.deployment.default-server.default-host./analysisapp: org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./analysisapp: java.lang.RuntimeException: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: VFS resource ["/C:/Users/developer/Documents/WildFly/bin/content/analysisapp.war/WEB-INF/classes/com/bizmerlin/config/EntityManagerFactoryConfiguration.class"]; nested exception is java.lang.annotation.AnnotationFormatError: Invalid default: public abstract java.lang.Class org.springframework.data.jpa.repository.config.EnableJpaRepositories.repositoryBaseClass()
at org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:85)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
at org.jboss.threads.JBossThread.run(JBossThread.java:320)
Caused by: java.lang.RuntimeException: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: VFS resource ["/C:/Users/developer/Documents/WildFly/bin/content/analysisapp.war/WEB-INF/classes/com/bizmerlin/config/EntityManagerFactoryConfiguration.class"]; nested exception is java.lang.annotation.AnnotationFormatError: Invalid default: public abstract java.lang.Class org.springframework.data.jpa.repository.config.EnableJpaRepositories.repositoryBaseClass()
at io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:224)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:100)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:82)
... 6 more
Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: VFS resource
【问题讨论】:
请在下面找到正在生成的日志,并且有两个战争文件 analysisapp.war 和 analysisapp-exec.war 并且都是在 .failed 模式下生成的。登录下一条评论 如果无法在此处发布日志,请使用 pastebin 我不确定,但我怀疑您是否可以在 Web 容器中运行批处理作业。也许你不想看Spring Batch configuration 请在下面的链接中找到完整的日志:pastebin.com/dy5gxPt2 @Patrick :我已经看到了那件事,因为我已经从那里阅读了原始文档,但问题是,该文档是以基于 xml 的格式给出的,我想在使用 bean 的基于 JAVA 的格式,您可以在下面看到我参考的示例:javacodegeeks.com/2015/03/spring-batch-tutorial.html 我正在寻找类似的东西。请指教。 【参考方案1】:最初的错误是:
java.lang.annotation.AnnotationFormatError:
Invalid default: public abstract java.lang.Class org.springframework.data.jpa.repository.config.EnableJpaRepositories.repositoryBaseClass()
您似乎遇到了版本问题。这可能是由于不兼容版本的spring类一起使用造成的。
通过 mvn 依赖查看您在两个模块中使用的版本:tree mvn dependency:tree
如果您发现差异,请更改 <version>
或使用 <dependencyManagement>
解决它们
编辑: 出现此警告是因为您在 'dependencyManagement' 和两个不同的版本中对 org.apache.poi:poi-ooxml 有两次依赖。
浏览你的 pom 并查看可能发生这种情况的位置。删除其中一个,它可以工作。
依赖管理
【讨论】:
@Stefab Isele - 为延迟响应道歉,但就像您建议的那样,我尝试了该命令,但没有看到任何预期的版本冲突。请在此处查看输出结果:pastebin.com/GTtKC9EY以上是关于现有项目的 Spring Batch Process 实现的主要内容,如果未能解决你的问题,请参考以下文章
Spring-Batch学习总结——重要概念,环境搭建,名词解释,第一个项目及异常处理