I am building a Spring Boot application using Bamboo. Is there any way I can read maven build related information like:
buildNumber and buildTimeStamp?
I have tried reading properties like below but they are not working.
#Value("${bamboo.buildNumber}")
private String buildNumber;
and
#Value("${buildNumber}")
private String buildNumber;
I think the bit I missing can be any of below:
Bamboo is not writing properties to Jar exported to Artifactory.
I am reading properties with wrong keys.
I am missing some POM configuration.
Any help is much appreciated.
The #Value notation reads values from a properties file when you run the spring application. There is no way that properties which existed in the Bamboo environment at the time that your spring app was built will be available when you run your spring app, unless you take steps to make them available.
You will need to build a .properties file during the Bamboo build, and have this packaged into your spring boot application.
Related
I am now to Spring profile and I have a question, if I am doing a environment specific build using maven like mvn -Ptest then do I need to provide SPRING_PROFILES_ACTIVE parameter on execution.
If I understand Spring Profile correctly, giving SPRING_PROFILES_ACTIVE will direct my spring boot application to pick up the necessary application properties/#profile beans then why do I need to do mvn -Ptest.
One point I came accross is that mvn -Ptest allows us to package our properties file accordingly but in that case, isnt using Spring Profile a better solution.
It will be great if someone can point any scenario wherein we have to use mvn -Ptest even if we are using spring profile in Java application.
I think you are confusing maven profiles with spring profiles.
Maven profiles allow you to execute builds with different build configurations. It is only used during the maven build process.
Spring profiles can allow you to load different property files and is available at runtime to do whatever you want.
Now, you may have a maven profile that executes your spring application with a spring profile set but the difference is build vs execution time.
I am using VS Code to compile and debug my Spring Boot Java project with help of Gradle. I recently added Redis dependency to my project. The project compiles in Eclipse, but throws error in VS Code.
I'm not sure this answer becomes helpful to you or not but,
Normally VS code is not comes with default configurational setting of spring boot.
Spring boot project not able to run without dependencies.
So Because of your project not able to find relevant dependencies so it is generate this errors.
It solved using download plugin of vscode-spring-initializer and / or others.
If you need more detail then,
Try recognize your spring boot project in different IDE like IntelliJ or Eclipes. You see that there is some extra files are there like following,
External Libraries - which handle by maven kind of tool for load dependency.
.iml file in intellij : File which handle development module(contain plugins, module and other details).
This files are not existing there so that it generate issue.(That are different based on IDE)
If you have recently modified the pom.xml or build.gradle config file, you need right click on pom.xml or build.gradle file and then run the menu "Update project configuration" to force the language server to update the project configuration/classpath. Otherwise, the java language server cannot recognize the newly added dependency.
I'm working on an application that utilizes the Spring Boot framework. I work exclusively out of IntelliJ, in which I've created a runtime configuration for Spring Boot. This configuration is IntelliJ-based and is capable of running and debugging the application utilizing the settings specified in both the project's application.properties and pom.xml files.
Up until about a week ago, my runtime configuration (upon debugging/running) launched the Spring Boot application, which in turn launched an embedded instance of Tomcat. Last week, without making any project-level setting changes, this configuration has started to run Jetty rather than Tomcat. Has anyone seen this?
Unfortunately, I'm not at liberty to share the properties or pom files in-depth, but I will point out that I have no mention of Jetty in either, and the following are listed as dependencies:
Thanks for taking a look!
I have a spring boot application that uses a database. I have the local configuration in the application.properties file. I understand it is possible to change the values when I build the project with maven. I want to set the production values (db on AWS).
Here is application.properties
spring.datasource.url=${db.url:jdbc:postgresql://localhost:5432/mydb}
spring.datasource.username=${db.username:localusername}
spring.datasource.password=${db.password:localpassword}
I would like to change the values when I run. This will create a docker image.
mvn package docker:build
Is it possible?
I have been trying to start a simple Spring project as a part of my study. From the tutorials (they are about a year old resources i am refering), it seems the Spring related libraries were easily available online then. But now; I was unable to get something like a "spring_ver_no.zip" from the spring source site. It is having options to download a tool suite which is about 350 MBs large.
Can you please guide me if that download is the way to setup a Spring development environment?If not what is the way to set up a simple Spring environment in eclipse.
Thanks
Angie
You should use a dependency management tool like Gradle or Maven, and let this tool download the libraries for you. See the quick start for how to include Spring in your dependencies. If you still want to download the jar files and add them manually to your project, then download them directly from the Maven central repository: http://search.maven.org/#search|ga|1|g%3A%22org.springframework%22
Spring is, for a long time, splitted in several modules. You have to download all the modules you need.
Spring is using Maven lately. You should use it too. Maven is a build tool and dependency manager that will ease your life.