The start of my Configuration file with path src/main/java/{package name}/DataBaseConfiguration.java:
@Configuration @PropertySource("classpath:application.properties") public class DataBaseConfiguration { private static final Logger LOGGER = LoggerFactory.getLogger("DataBaseConfiguration.class"); @Value("${tenantdb.driver.classname}") static String tenantDbDriverClassname; @Value("${tenantdb.url}") static String tenantDbUrl; @Value("${tenantdb.username}") static String tenantDbUsername; @Value("${tenantdb.password}") static String tenantDbPassword; My application.properties file with path src/main/resources/application.properties:
tenantdb.driver.classname=org.postgresql.Driver tenantdb.url=jdbc:postgresql://127.0.0.1:5000/tenant_db tenantdb.username=tenant_admin_user tenantdb.password=postgres tenantdb.connectionpool.initialSize=3 tenantdb.connectionpool.maxActive=25 tenantdb.connectionpool.maxIdle=25 tenantdb.connectionpool.minIdle=1 I am using gradle to build the project. I convert things into a JAR and run the JAR as $java -jar /path/to/jar. The code executes and runs and all my print debugging statements are logged. However the values of my variables are all null i.e. things are not being read from the properties file.
I have made sure that the application.properties file is in the JAR.
Files in archive integrity-check-service.jar
META-INF/ META-INF/MANIFEST.MF BOOT-INF/ BOOT-INF/classes/ BOOT-INF/classes/com/ BOOT-INF/classes/com/agilysys/ BOOT-INF/classes/com/agilysys/analytics/ BOOT-INF/classes/com/agilysys/analytics/integritycheckservice/ BOOT-INF/classes/com/agilysys/analytics/integritycheckservice/CompareData.class BOOT-INF/classes/com/agilysys/analytics/integritycheckservice/DataBaseConfiguration.class BOOT-INF/classes/application.properties (There are other files but I haven't printed them all here.)
Does anyone know why this is happening?