Spring boot build without starting up the application - spring-boot

I want to build the spring boot jar file using maven like
mvn -B clean install -Pdev -DskipTests
But I do not want to start the spring boot app while doing this process as it cannot connect to the database from this build machine. How can I do that? Now the build is failing as it is trying to start up the server during the build process

Related

Vaadin 14 Spring Boot App run from command line in ProductionMode

I want to run the spring boot application from a jar with embedded tomat, like I run other spring-boot apps.
The project is running fine, when started from IDE.
I want to run it from jar, but i get this error in the browser:
Failed to find the bundle manifest file 'frontend://vaadin-flow-bundle-manifest.json' in the servlet context for 'ES6' browsers.
I have set the productionMode to true in both application.properties and pom.xml. Why it is such a hustle? I don't know how to produce this json file. How to just run this project even in dev mode?
I start the project with:
mvn clean && mvn package -Pproduction && mvn spring-boot:run -Pproduction

Is there any meaning to running -Dspring.profiles.active=dev,runtime when running Spring Boot locally?

In my team I frequently (>10) see Spring Boot projects with the following instructions for running locally:
mvn clean spring-boot:run -Dspring.profiles.active=dev,runtime
My understanding of Spring Boot profiles is that each one corresponds to a particular environment, eg dev, test - so you would never need more than one. Also that each profile name corresponds to a particular env file - eg src/main/java/resources/application-dev.yml application-test.yml etc.
I would have thought that you would run the app on your local machine with:
mvn clean spring-boot:run -Dspring.profiles.active=local
And have the local configuration in:
src/main/java/resources/application-local.yml
This is running:
Java 11
maven parent is org.springframework.boot spring-boot-starter-parent 2.2.6.RELEASE
maven version is 3.3.9
My question is: Is there any meaning to running -Dspring.profiles.active=dev,runtime when running Spring Boot locally?

spring boot: maven command to download all dependencies

In a spring boot project I would like to download all dependencies before starting the application.
When I run "mvn compile" first, it is downloading a lot of dependecies. But when I run "mvn spring-boot:run" after that, it still downloads tons of dependecies.
So what is the right way to download all dependecies like spring-boot:run does - but without running the application?
Thank you!
Try running maven with -o switch to run your maven command in offline mode. This will use already downloaded dependencies in the local repository.

Running API tests in Teamcity build step

I have a Spring Boot Maven app. There is a bunch of API tests using RestAssured, inside the project. These tests are not marked as #SpringBootTest, therefore when running them, the context of the application is not raising so to make tests pass the application must be up and running before.
I'm creating a Teamcity build in which I want to:
Start the app
Run RestAssured tests
Create an artifact
I'm using an Agent with maven installed.
The question is:
How can I create a build step where I run the application on a defined port and then run api tests
against it?
What I've tried is creating such build steps:
Command line: mvn spring-boot:run & sleep 50s mvn test
Maven step/command line: mvn clean package -DskipTests
I thought the spring boot application will start and tests will be ready to start after some time. On successful step 1 I create an artifact.
The problem is that the build step is never exited because of spring boot app running (blocking terminal).

Maven build - run an application then perform JUnit tests

As part of my build process, I would like maven to start a program and then execute JUNIT tests in the same phase, which is the mvn test phase.
I am using Spring Boot as well as the Spring Boot Maven plugin. As you know Spring boot has an embedded tomcat container. So I can just run my application on this tomcat server by just running as an application in eclipse.
For example when I run mvn test, I would like my application to run FIRST and then have the tests executed.
I have seen the exec-maven plugin being used and that you specify the phase in the maven build cycle that you want the application to run. The earliest phase that it allows you to specify is the test phase.
But I'm not sure if the Application will run immediately before the tests?
How do I specify in my POM file that I want the application to run BEFORE the test phase?

Resources