G
G
gsaw2021-02-09 14:08:26
Java
gsaw, 2021-02-09 14:08:26

How to run spring application from jar file from classpath?

Hello,

I need to run a spring application on z/OS. There I can only specify the class name with the main method and set the CLASSPATH. And there it is accepted foolish versioning. The name of the module plus the version number and the admin requires that in each new version of the application I change the class name accordingly and the class must lie in a certain path. Like this

com.somecompanyname.batch.MYAPPL01.

Then the new version will have

com.somecompanyname.batch.MYAPPL02.

The question is, is it possible to somehow launch a spring application by specifying some kind of class inherited from JarLauncher? How can I add it to the fat jar in parallel with the JarLauncher classes?

Previously, everything was without spring, it was simple. And now I wanted to transfer everything to spring and some troubles. z/OS is generally a great axis....from others.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
BorLaze, 2021-02-10
@BorLaze

Maybe I didn't understand something, but...
spring-boot-maven-plugin makes it not easy, but very simple

<build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>${spring-boot.version}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                        <configuration>
                            <mainClass>${application.mainClass}</mainClass>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

the resulting jar can be run without specifying a specific class (it will run what is specified in application.mainClass):
java -jar application.jar
Moreover, if you add a flag to the plugin
<configuration>
    <executable>true</executable>
</configuration>

then the archive itself will become executable and can be run directly
./application.jar

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question