Spring boot devtools does not consider exclude property - spring-boot

I am using Spring Boot with Gradle and added the Devtools plugin. My application is creating files in src/main/resources so I don't want it to be restarted when this is changed. I have tried the following settings in application config file:
spring.devtools.restart.exclude= src/main/resources
spring.devtools.restart.exclude= resources
spring.devtools.restart.exclude= resources/**
spring.devtools.restart.exclude= src/main/resources/**
but none worked.
How can I configure spring boot devtools to ignore files changed in resources folder?

Related

Properties are not found in Spring Boot application

I have a Spring Boot + JSF (Primefaces) integrated project
git clone https://iva-nova-e-katerina#bitbucket.org/iva-nova-e-katerina/jsf-springboot.git
And build it with mvn package then run with
cd target
java -jar ./JSF-springboot-demo-0.0.1-SNAPSHOT.war
And when I check http://localhost:8080/index.xhtml I can see that there are no messages on the page. The messages are the strings in the properties files, which are bundled into WAR file, but it seems like Primefaces can't see them https://bitbucket.org/iva-nova-e-katerina/jsf-springboot/src/master/src/main/resources/. Could you help me to fetch this properties files inside Spring Boot application?

Spring boot jar file, not reading application.properties in config folder

I have a jar file from a Spring Boot project created with "mvn clean install". I created a folder named "config" and placed the "application.properties" in that folder
However the application is still not using the external application.properties file, but it's using the one inside the jar file. How can I make it use the external application.properties if it exists.

what is reason the spring boot application doesn't read application.properties file?

i have a maven project then i'm manually added a 'src/main/resources' directory and application.properties but it can't read the application.properties file;
How can i convert my maven project to spring boot project ?
You need to say your IDE that src/main/resources is a source folder.
Try a maven plugin (e.g. for Eclipse http://maven.apache.org/plugins-archives/maven-eclipse-plugin-2.8/eclipse-mojo.html),
do it manually
start your application using the maven spring-boot plugin
mvn spring-boot:run
http://docs.spring.io/spring-boot/docs/current/maven-plugin/usage.html

spring-boot - External log4j configuration not working

I am trying to do a setup for production environment, so I wanted to keep log4j.properties out of my application jar file.
For that I have kept my application.properties and log4j.properties files parallel to my spring-boot jar file. And I have given logging.config: file:log4j.properties in my application.properties. This doesn't seem to work. Spring is still picking up the log4j.properties file which is placed inside the jar file.
I have tried giving the absolute path in logging.config property like C:\Users\furquan\project\jars\log4j.properties, but it still the log4j.properties that was being used was the one inside the jar file.
Please help, its important !!!
-Dlogging.config=/path/to/log4j.properties
Or you can specify it in your application.properties or bootstrap.properties.
From 26.5 Custom log configuration
And just a note:
After spring boot 1.4, Log4j 1 support has been removed. So maybe you can consider use the default logback, or use log4j2 instead.

Springboot externalizing log4j configuration

In a springboot application, I have a single jar, and then a subdirectory config with application.properties, applicationContext.xml, and log4j...properties file.
I am trying to externalize the log4j config. The application.properties is externalized this way.
But, when springboot runs it is using the log4j config file from within the jar file. By using the -Dlog4j.debug option I can see that log4j uses my external file first, but when spring starts it overrides the log4j setting with the one in the jar.
here is an example startup (with all options)
java -Dlog4j.debug
-Dlogging.config="file:/opt/config/log4j-qa.properties"
-Dlog4j.configuration="file:/opt/config/log4j-qa.properties"
-jar /opt/myjarName.jar
--spring.config.location=/opt/config/
on first startup log4j states
log4j: Reading configuration from URL file:/opt/config/log4j-qa.properties
then on springboot start
log4j: Reading configuration from URL jar:file:/opt/dms-events-api.jar!/log4j-qa.properties
but I want it to read only the external file file:/opt/config/log4j-qa.properties
resolution:
In our application we had line
#ImportResource("classpath:applicationContext.xml")
which then defined the log4j properties file from the classpath:
the simple solution
1. create a /config directory at the root of the api application and put the properties files there
2. remove the ImportResource line, it isn't needed now
3. add a line to the the application.properties file
logging.config=file:config/log4j-${our environment var}.properties
the explanation
By creating a /config directory at the root of the project then
we can work in eclipse as usual and find our properties files.
--and then to externalize configs
simply add a config directory off of where the application jar is and put properties files there.
Two problems are there:
Configuration for externalise: - Tried and works below one for me in spring boot jar
-Dlog4j.configuration=file:/Users/test/Any-Folder/log4j.properties
Spring logging takes over - for that you need to exclude the logging module. PFB the config for Gradle build.
configurations {
all*.exclude module : 'spring-boot-starter-logging'
}

Resources