简体   繁体   中英

Spring Boot war packaging: Execution with additional classpath

I would like to package my Spring Boot application as a war package in order to

  • deploy on existing tomcat
  • running standalone with java -jar application.war

with the same artifact. To achieve this I set the scope of spring-boot-starter-tomcat to provided so these dependencies are located in folder lib-provided .

I don't want to include the Database driver in the artifact. When running on existing tomcat I just add the database driver (as jar) to its lib folder.

Now my question: How can I add the additional classpath (eg lib/* ) to the java -jar application.war command? Traditional approaches (like java -cp lib/* -jar application.war ) did not work.

Found out that Spring Boot uses a WarLauncher to run executable war files. So

 java -cp drivers/*:application.war org.springframework.boot.loader.WarLauncher

is a working commandline command to add additional jar files to the classpath without modifying or unpacking the war file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM