关于使用spring_batch2.1.8的sample的运行
问题一:在执行项目"spring-batch-parent"的时候出现下面的异常信息:
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.springsource.bundlor:com.springsource.bundlor.maven:1.0.0.RELEASE:bundlor (bundlor-transform) on project spring-batch-parent: Execution bundlor-transform of goal com.springsource.bundlor:com.springsource.bundlor.maven:1.0.0.RELEASE:bundlor failed: Unable to load the mojo 'bundlor' in the plugin 'com.springsource.bundlor:com.springsource.bundlor.maven:1.0.0.RELEASE'. A required class is missing: com/springsource/bundlor/support/classpath/ClassPathFactory
-----------------------------------------------------
realm =??? plugin>com.springsource.bundlor:com.springsource.bundlor.maven:1.0.0.RELEASE
strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
urls[0] = file:/D:/maven-3.0.1/repository/com/springsource/bundlor/com.springsource.bundlor.maven/1.0.0.RELEASE/com.springsource.bundlor.maven-1.0.0.RELEASE.jar
urls[1] = file:/D:/maven-3.0.1/repository/org/codehaus/plexus/plexus-utils/1.1/plexus-utils-1.1.jar
Number of foreign imports: 1
import: Entry[import? from realm ClassRealm[project>org.springframework.batch:spring-batch-parent:2.1.8.RELEASE, parent: ClassRealm[maven.api, parent: null]]]
-----------------------------------------------------
?at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:211)
?at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148)
?at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:140)
?at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
?at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
?at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
?at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
?at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:316)
?at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:153)
?at org.apache.maven.cli.MavenCli.execute(MavenCli.java:451)
?at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:188)
?at org.apache.maven.cli.MavenCli.main(MavenCli.java:134)
?at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
?at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
?at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
?at java.lang.reflect.Method.invoke(Method.java:585)
?at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
?at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
?at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
?at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution bundlor-transform of goal com.springsource.bundlor:com.springsource.bundlor.maven:1.0.0.RELEASE:bundlor failed: Unable to load the mojo 'bundlor' in the plugin 'com.springsource.bundlor:com.springsource.bundlor.maven:1.0.0.RELEASE'. A required class is missing: com/springsource/bundlor/support/classpath/ClassPathFactory
-----------------------------------------------------
realm =??? plugin>com.springsource.bundlor:com.springsource.bundlor.maven:1.0.0.RELEASE
strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
urls[0] = file:/D:/maven-3.0.1/repository/com/springsource/bundlor/com.springsource.bundlor.maven/1.0.0.RELEASE/com.springsource.bundlor.maven-1.0.0.RELEASE.jar
urls[1] = file:/D:/maven-3.0.1/repository/org/codehaus/plexus/plexus-utils/1.1/plexus-utils-1.1.jar
Number of foreign imports: 1
import: Entry[import? from realm ClassRealm[project>org.springframework.batch:spring-batch-parent:2.1.8.RELEASE, parent: ClassRealm[maven.api, parent: null]]]
-----------------------------------------------------
?at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:121)
?at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:195)
?... 19 more
Caused by: org.apache.maven.plugin.PluginContainerException: Unable to load the mojo 'bundlor' in the plugin 'com.springsource.bundlor:com.springsource.bundlor.maven:1.0.0.RELEASE'. A required class is missing: com/springsource/bundlor/support/classpath/ClassPathFactory
-----------------------------------------------------
realm =??? plugin>com.springsource.bundlor:com.springsource.bundlor.maven:1.0.0.RELEASE
strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
urls[0] = file:/D:/maven-3.0.1/repository/com/springsource/bundlor/com.springsource.bundlor.maven/1.0.0.RELEASE/com.springsource.bundlor.maven-1.0.0.RELEASE.jar
urls[1] = file:/D:/maven-3.0.1/repository/org/codehaus/plexus/plexus-utils/1.1/plexus-utils-1.1.jar
Number of foreign imports: 1
import: Entry[import? from realm ClassRealm[project>org.springframework.batch:spring-batch-parent:2.1.8.RELEASE, parent: ClassRealm[maven.api, parent: null]]]
-----------------------------------------------------
?at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getConfiguredMojo(DefaultMavenPluginManager.java:441)
?at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:96)
?... 20 more
Caused by: java.lang.NoClassDefFoundError: com/springsource/bundlor/support/classpath/ClassPathFactory
?at java.lang.Class.getDeclaredConstructors0(Native Method)
?at java.lang.Class.privateGetDeclaredConstructors(Class.java:2357)
?at java.lang.Class.getDeclaredConstructors(Class.java:1808)
?at com.google.inject.spi.InjectionPoint.forConstructorOf(InjectionPoint.java:243)
?at com.google.inject.internal.ConstructorBindingImpl.create(ConstructorBindingImpl.java:96)
?at com.google.inject.internal.InjectorImpl.createUninitializedBinding(InjectorImpl.java:609)
?at com.google.inject.internal.InjectorImpl.createJustInTimeBinding(InjectorImpl.java:816)
?at com.google.inject.internal.InjectorImpl.createJustInTimeBindingRecursive(InjectorImpl.java:750)
?at com.google.inject.internal.InjectorImpl.getJustInTimeBinding(InjectorImpl.java:235)
?at com.google.inject.internal.InjectorImpl.getBindingOrThrow(InjectorImpl.java:185)
?at com.google.inject.internal.InjectorImpl.getInternalFactory(InjectorImpl.java:824)
?at com.google.inject.internal.InjectorImpl.getProviderOrThrow(InjectorImpl.java:938)
?at com.google.inject.internal.InjectorImpl.getProvider(InjectorImpl.java:971)
?at com.google.inject.internal.InjectorImpl.getProvider(InjectorImpl.java:932)
?at com.google.inject.internal.InjectorImpl.getInstance(InjectorImpl.java:984)
?at org.sonatype.guice.bean.reflect.AbstractDeferredClass.get(AbstractDeferredClass.java:48)
?at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:40)
?at com.google.inject.internal.InjectorImpl$4$1.call(InjectorImpl.java:949)
?at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:995)
?at com.google.inject.internal.InjectorImpl$4.get(InjectorImpl.java:945)
?at com.google.inject.Scopes$1$1.get(Scopes.java:59)
?at org.sonatype.guice.bean.locators.LazyQualifiedBean.getValue(LazyQualifiedBean.java:66)
?at org.sonatype.guice.plexus.locators.LazyPlexusBean.getValue(LazyPlexusBean.java:54)
?at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:247)
?at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:239)
?at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getConfiguredMojo(DefaultMavenPluginManager.java:422)
?... 21 more
[ERROR]
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginContainerException
解决方法:
?????????? 就是把找到spring-batch-parent项目中的pom.xml文件,然后把下面的
???<plugin>
????<groupId>com.springsource.bundlor</groupId>
????<artifactId>com.springsource.bundlor.maven</artifactId>
????<version>${bundlor.version}</version>
????<inherited>true</inherited>
????<executions>
?????<execution>
??????<id>bundlor-transform</id>
??????<phase>compile</phase>
??????<goals>
???????<goal>bundlor</goal>
??????</goals>
?????</execution>
????</executions>
???</plugin>
就是把上面的红色字体的部分改成<phase>runtime</phase> 即可解决问题
问题2:在项目"spring-batch-simple-cli"打包的时候出现下面的异常信息
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-jar-plugin:2.3.1:jar (default-jar) on project spring-batch-simple-cli: Error assembling JAR: Manifest file: D:\citic\spring_batch\spring-batch-2.1.8.RELEASE\samples\spring-batch-simple-cli\target\classes\META-INF\MANIFEST.MF does not exist. -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-jar-plugin:2.3.1:jar (default-jar) on project spring-batch-simple-cli: Error assembling JAR
?at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:203)
?at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148)
?at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:140)
?at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
?at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
?at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
?at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
?at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:316)
?at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:153)
?at org.apache.maven.cli.MavenCli.execute(MavenCli.java:451)
?at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:188)
?at org.apache.maven.cli.MavenCli.main(MavenCli.java:134)
?at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
?at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
?at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
?at java.lang.reflect.Method.invoke(Method.java:585)
?at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
?at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
?at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
?at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: org.apache.maven.plugin.MojoExecutionException: Error assembling JAR
?at org.apache.maven.plugin.jar.AbstractJarMojo.createArchive(AbstractJarMojo.java:223)
?at org.apache.maven.plugin.jar.AbstractJarMojo.execute(AbstractJarMojo.java:235)
?at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:107)
?at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:195)
?... 19 more
Caused by: org.codehaus.plexus.archiver.ArchiverException: Manifest file: D:\citic\spring_batch\spring-batch-2.1.8.RELEASE\samples\spring-batch-simple-cli\target\classes\META-INF\MANIFEST.MF does not exist.
?at org.codehaus.plexus.archiver.jar.JarArchiver.setManifest(JarArchiver.java:211)
?at org.apache.maven.archiver.MavenArchiver.createArchive(MavenArchiver.java:510)
?at org.apache.maven.plugin.jar.AbstractJarMojo.createArchive(AbstractJarMojo.java:216)
?... 22 more
[ERROR]
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
解决方法如下:
需要找到改项目"spring-batch-simple-cli"中的pom.xml配置文件找到下面的配置代码进行更改:
??<plugin>
????<groupId>org.apache.maven.plugins</groupId>
????<artifactId>maven-jar-plugin</artifactId>
????<configuration>
?????<archive>
??????<index>false</index>
??????<manifest>
???????<mainClass>org.springframework.batch.core.launch.support.CommandLineJobRunner</mainClass>
???????<addClasspath>true</addClasspath>
???????<classpathPrefix>lib/</classpathPrefix>
??????</manifest>
??????<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
?????</archive>
????</configuration>
???</plugin>
?需要更改红色的部分,把<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>更改为下面的内容
<manifestFile>${project.build.outputDirectory}/META-INF/template.mf</manifestFile>
然后把项目中的template.mf的文件copy到该项目中的"src/main/resources/META-INF"的目录下面即可
然后进行package就不会再出现下面的问题。
问题3:在项目"spring-batch-simple"打包的时候出现和问题2中出现的一样的异常
解决方法:
打开项目"spring-batch-parent"的项目,然后打开pom.xml配置文件
????<plugin>
?????<artifactId>maven-jar-plugin</artifactId>
?????<version>2.3</version>
?????<configuration>
??????<archive>
???????<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
??????</archive>
?????</configuration>
????</plugin>
? 然后把上面的红色的部分更改为下面的内容:
?????? <manifestFile>${project.build.outputDirectory}/META-INF/template.mf</manifestFile>即可
然后打开项目"spring-batch-samples",把该项目中的"template.mf"的文件copy到该项目的src/main/resources下面的META-INF的目录下面
然后使用maven的package即可
?
若还有其他的问题则在改pom中加入如下的代码:
?
?
<repositories>
??<repository>
???<id>com.springsource.repository.bundles.external</id>
???<name>SpringSource Enterprise Bundle Repository - SpringSource Bundle External</name>
???<url>http://repository.springsource.com/maven/bundles/external</url>
???<snapshots>
????<enabled>false</enabled>
???</snapshots>
??</repository>
??<repository>
???<id>com.springsource.repository.bundles.snapshot</id>
???<name>SpringSource Enterprise Bundle Repository -
????SpringSource Bundle Snapshots</name>
???<url>http://repository.springsource.com/maven/bundles/snapshot</url>
??</repository>
??<repository>
???<id>com.springsource.repository.bundles.milestone</id>
???<name>SpringSource Enterprise Bundle Repository -
????SpringSource Bundle Milestones</name>
???<url>http://repository.springsource.com/maven/bundles/milestone</url>
???<snapshots>
????<enabled>false</enabled>
???</snapshots>
??</repository>
??<repository>
???<id>com.springsource.repository.bundles.release</id>
???<name>SpringSource Enterprise Bundle Repository -
????SpringSource Bundle Releases</name>
???<url>http://repository.springsource.com/maven/bundles/release</url>
???<snapshots>
????<enabled>false</enabled>
???</snapshots>
??</repository>
??? <repository>
??????? <id>springsource-releases</id>
??????? <name>SpringSource Release Proxy</name>
??????? <url>https://oss.sonatype.org/content/repositories/springsource-releases</url>
????? </repository>
??
?</repositories>