I packaged my spring boot application into a jar and I made it as a web service via apache tomcat 9 with a .bat file.
on the other hand the externalization of application-prod.yml does not work and the .yml file is ignored in the same path as the jar.
how can I do it please
use packaging tools to package,such as maven.
if you use maven,you should config packaging plugins
you may check the official document, and as your .yml file is already in the same path as the jar file, you may try this :
java -jar myproject.jar --spring.config.location=/path/to/your/yaml
Related
I have a Spring Boot Java application with property yaml files located under resources folder.
I packaged it in maven using jar format. But the issue is whenever there's a change required in the yaml file I will have to redeploy the jar file.
Is there any way to build the jar file with the reference to yaml files remain outside of the jar?
I'm trying to run my camel application on external tomcat. There are 2 application.properties files present in my project, one under src/main/resources and other under src/test/resources. When I create war file using maven install command, it uses the application.properties file from src/main/resources (which is needed) but when I start the application using tomcat in eclipse, it is using application.properties file from src/test/resources. I've also removed classpath entry of src/test/resources from eclipse but no luck. I'm not really sure how is it picking the application.properties file from src/test/resources.
When I delete the application.properties file present under src/test/resources then it works fine i.e. then it picks the application.properties file present under src/main/resources.
We are using:
Oracle JDK 8
Spring 4.3.11.RELEASE
Tomcat 8.5
Camel 2.20.2
ActiveMQ 5.15.0
Maven Build Tool
Thanks in advance.
When Eclipse deploys a project to a server the important setting is the "Deployment Assembly", not the "Java Build Path". If you remove the src/test/resources folder from the deployment assembly, the files it contains will not be copied.
I have a single jar server app (simple web portal) built with Spring Boot. I run it:
java -jar myapp.jar
Locally, the jar file is under my Eclipse project folder. Now it's ready to be deployed on a Linux server as a service. What folder should I create on the server to put the jar file? In that folder (working directory), I will be putting the application.yaml file plus some other config files. The service will run as root.
Create a directory under either /opt or /usr and have your jar run from there.
If your app creates one log file, configure it for /var/log. If it's going to write a few create a directory /var/log/<your app>.
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 (e.g. 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.
I'm using maven and the embedded tomcat through the tomcat-maven-plugin to run my Spring MVC project. Now I've got a another war file which I also want to run on this tomcat. Is there a way to achieve this? It doesn't seem to work, when I put the war file in the webapps folder of the embedded tomcat.
support of this feature is in snapshot version of the plugin see https://issues.apache.org/jira/browse/MTOMCAT-169