Framework/Spring Framework
표준프레임워크 batch-commandLine 실행가능한 jar로 만들기
후늬뉨
2020. 10. 19. 15:02
부트없이 표준프레임워크 배치 템플릿(commandline)을 jar로 묶는 방법이다.
pom.xml 에 아래의 build 설정을 해주고 build를 하면 실행가능한 jar를 만들수 있다.
표프의 배치템플릿에 부트 도입이 시급하다..
<build>
<defaultGoal>install</defaultGoal>
<directory>${basedir}/target</directory>
<finalName>egovframework.example.bat.template.sam.commandline</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.6</version>
<configuration>
<archive>
<index>true</index>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>egovframework.example.bat.commandline.EgovCommandLineJobRunner</mainClass>
</manifest>
<manifestEntries>
<mode>development</mode>
<url>${pom.url}</url>
<key>value</key>
</manifestEntries>
</archive>
</configuration>
</plugin>
</plugins>
</build>
job파일 수정
/batch-cmdline-standalone/src/main/resources/egovframework/batch/job/delimitedToDelimitedJob.xml
reader
<property name="resource" value="classpath:/egovframework/batch/data/inputs/csvData.csv" />
writer
<property name="resource" value="file:./test-outputs/csvOutput.csv" />
실행명령어
java -cp "C:/eGovFrame-3.9.0/workspace.edu/batch-cmdline-standalone/target/egovframework.example.bat.template.sam.commandline.jar;C:/eGovFrame-3.9.0/workspace.edu/batch-cmdline-standalone/target/lib/*" egovframework.example.bat.commandline.EgovCommandLineJobRunner /egovframework/batch/context-commandline.xml delimitedToDelimitedJob