我有一个独立的应用程序,它通过一个main方法启动,该方法基于Spring Framework并使用JavaFX作为用户界面。
目前有一个主类,它解析命令行参数并根据结果设置Spring配置。有三种不同的配置:
使用当前的方法,我可以决定Spring配置,但是使用Spring Boot,应用程序基本上成为顶级配置。
这使我得出结论,我将需要三个独特的Spring Boot应用程序。由于整个项目是使用Maven建立的,因此主要类别在一个模块中依赖于所有其他模块。我还设置了Maven构建来创建可执行jar,以及可执行应用程序。
如果我有三个不同的Spring Boot应用程序,那是否意味着我需要将它们放在不同的模块中?
基于此构建配置:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>ch.sahits.game.OpenPatrician</mainClass>
<addClasspath>true</addClasspath>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>com.zenjava</groupId>
<artifactId>javafx-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>unix</id>
<activation>
<os><family>unix</family></os>
</activation>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>com.zenjava</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<configuration>
<mainClass>ch.sahits.game.OpenPatrician</mainClass>
<verbose>true</verbose>
<bundler>linux.app</bundler>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build> </profile>
<profile>
<id>windows</id>
<activation>
<os><family>windows</family></os>
</activation>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>com.zenjava</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<configuration>
<mainClass>ch.sahits.game.OpenPatrician</mainClass>
<verbose>true</verbose>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</profile>
<profile>
<id>build-installer</id>
<properties>
<native.output.dir>${project.build.directory}/jfx/native/${project.build.finalName}</native.output.dir>
<native.output.dir.app>${native.output.dir}/app</native.output.dir.app>
<native.app.jar>${native.output.dir.app}/${project.build.finalName}-jfx.jar</native.app.jar>
</properties>
<dependencies>
<dependency>
<groupId>ch.sahits.game</groupId>
<artifactId>OpenPatricianDisplay</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.zenjava</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>native</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>create zip archive</id>
<phase>install</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<echo>Creating self-contained zip native</echo>
<zip destfile="${project.build.directory}/OpenPatrician-${project.version}-[OS]64.zip" basedir="${native.output.dir}" />
<echo>Creating self-contained executable jar</echo>
<zip destfile="${project.build.directory}/OpenPatrician-${project.version}.zip" basedir="${native.output.dir.app}" />
</target>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
我应该更改为Spring Boot方式来创建可执行的Jar文件,还是这种方法仍然有用?