I cloned the hapi-fhir-jpaserver-starter and modified the code to meet my requirements then did as they said in the README file:
mvn clean install
docker-compose up -d --build
It did deploy the server but with a new fresh HAPI server, not the one I modified and built.
How can I use docker compose to deploy my build not the version he gets from the docker repo?
You most likely need to update the DockerFile to use your modified code, from your fork, rather than from the original repository:
ARG HAPI_FHIR_STARTER_URL=https://github.com/path/to/your/repo
ARG HAPI_FHIR_STARTER_BRANCH=your_branch
Alternatively, perhaps have a look if this commit resolved the issue for you? https://github.com/hapifhir/hapi-fhir-jpaserver-starter/commit/213bda7cfcc2d5f6f150b8781093b315a17a43c2
I want to setup a CI pipeline in GitLab for my Java project managed with Maven.
This is my gitlab-ci.yml
image: maven:3-jdk-9
variables:
MAVEN_CLI_OPTS: "--batch-mode"
stages:
- build
compile:
stage: build
script:
- mvn $MAVEN_CLI_OPTS compile
I always get the following exception:
I tried many things like changing versions of the plugins, various docker images, including a settings.xml and local repository in the project itself, but nothing works.
Thanks in advance for any help!
UPDATE:
Using the latest docker image everything works.
It seems like the CI server has no connection to the internet. Check this using the curl command in your .gitlab-ci.ymlfile.
But I'm pretty sure you guys at daimler have a local mirror, something like Artifactory.
In that case you have to use a settings.xml file.
Here is the official tutorial of Gitlab
I am dockerizing my Java applications by maven docker plugin.
I found a simple docker-maven-plugin that creates a simple docker file..
I want to know how to convert docker file command such as ADD,COPY,VOLUME etc. in to maven xml entries ?
I mean I need to be able to customize my dockerfile through maven pom.xml
I could not find any documentations or tutorial for this ...
Thanks for your input.
I have an application.properties file with default variable values. I want to be able to change ONE of them upon running with mvn spring-boot:run. I found how to change the whole file, but I only want to change one or two of these properties.
You can pass in individual properties as command-line arguments. For example, if you wanted to set server.port, you could do the following when launching an executable jar:
java -jar your-app.jar --server.port=8081
Alternatively, if you're using mvn spring-boot:run with Spring boot 2.x:
mvn spring-boot:run -Dspring-boot.run.arguments="--server.port=8081"
Or, if you're using Spring Boot 1.x:
mvn spring-boot:run -Drun.arguments="--server.port=8081"
You can also configure the arguments for spring-boot:run in your application's pom.xml so they don't have to be specified on the command line every time:
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<arguments>
<argument>--server.port=8085</argument>
</arguments>
</configuration>
</plugin>
To update a little things, the Spring boot 1.X Maven plugin relies on the --Drun.arguments Maven user property but the Spring Boot 2.X Maven plugin relies on the -Dspring-boot.run.arguments Maven user property.
So for Spring 2, you need to do :
mvn spring-boot:run -Dspring-boot.run.arguments="--server.port=8081"
And if you need to pass multiple arguments, you have to use , as separator and never use whitespace between arguments :
mvn spring-boot:run -Dspring-boot.run.arguments="--server.port=8081,--foo=bar"
About the the maven plugin configuration and the way of passing the argument from a fat jar, it didn't change.
So the very good Andy Wilkinson answer is still right.
Quick update:
if you are using the latest versions of spring-boot 2.X and maven 3.X, the below command line will override your server port:
java -jar -Dserver.port=9999 your_jar_file.jar
If not working with comma, to override some custom properties or spring boot properties in multiple mode, use whitespace instead of comma, like this code bellow:
mvn spring-boot:run -Dspring-boot.run.arguments="--server.port=8899 --your.custom.property=custom"
You can set an environment variable to orverride the properties. For example, you have an property name test.props=1 . If you have an environment variable TEST_PROPS spring boot will automatically override it.
export TEST_PROPS=2
mvn spring-boot:run
You can also create a json string with all the properties you need to override and pass it with -Dspring.application.json or export the json with SPRING_APPLICATION_JSON.
mvn spring-boot:run -Dspring.application.json='{"test.props":"2"}'
Or just pass the properties with -Dtest.props=2
mvn spring-boot:run -Dtest.props=2
Tested on spring boot 2.1.17 and maven 3.6.3
Running by Gradle:
Run in default port(8080): ./gradlew bootRun
Run in provided port(8888): ./gradlew bootRun --args='--server.port=8888'
If we have any variable in the application.properties file named PORT, run this: PORT=8888 ./gradlew bootRun
Running by Maven:
Run in default port(8080): mvnw spring-boot:run
Run in provided port(8888): mvnw spring-boot:run -Dspring-boot.run.jvmArguments='-Dserver.port=8085'
Run in provided port(8888): mvn spring-boot:run -Dspring-boot.run.arguments='--server.port=8085'
Run in provided port(8888) with other custom property: mvn spring-boot:run -Dspring-boot.run.arguments="--server.port=8899 --your.custom.property=custom"
If we have any variable in the application.properties file named PORT, run this: SERVER_PORT=9093 mvn spring-boot:run
Using java -jar:
Create the .jar file:
For Gradle: ./gradlew clean build. We will find the jar file inside: build/libs/ folder.
For Maven: mvn clean install. We will find the jar file inside:target folder.
Run in default port(8080): java -jar myApplication. jar
Run in provided port(8888): java -jar myApplication.jar --port=8888
Run in provided port(8888): java -jar -Dserver.port=8888 myApplication.jar
Run in provided port(8888) having variable SERVER_PORT in application.properties file: SERVER_PORT=8888 java -jar target/myApplication.jar
In Spring Boot we have provision to override properties as below
mvn spring-boot:run -Dspring-boot.run.arguments=--server.port=8082
If you have the jar file after doing mvn clean install, you can override any property that you have in your application.yml using the double -, like this:
java -jar name_of_your_jar_file.jar --parameter=value
For example, if you need to change your server port when starting you server, you can write the following:
java -jar name_of_your_jar_file.jar --server.port=8888
I Was making a mistake with the syntax of commandline command , while passing command-line arguments, I was wrapping multiple arguments between " " and this was the issue. I simply ran the same command having multiple arguments separated by a space without wraaping them between "" and it worked just fine.
Please note this answer is for cases where we are trying to run this scenario from a jar file(not using mvn).
Correct Command: java -jar myJar.jar --com.arg1=10 --com.arg2=1
Incorrect Command: java -jar myJar.jar "--com.arg1=10 --com.arg2=1"
I am looking for most efficient way to pass parameters to maven through idea 14 (I have just started working with idea).
When I want to compile and deploy my application through maven itself, I just run this command mvn clean package tomcat7:redeploy -P localhost -Daugage_env=local.
I dont know, how to pass this parameter -Daugage_env=local as default (or how to integrate it with localhost profile, which would be even better).
I did try maven-projects->myproject->lifecycle->right click on compile and create custom compile where I changed the Command line text to compile -Daugage_env=local, but it does not work.
You can define profile specific properties directly in pom.xml like so:
<profile>
<id>localhost</id>
<properties>
<augage_env>local</augage_env>
</properties>
</profile>
More information can be found in Maven documentation for build profiles.