Tomcat8 Springboot not reading application.properties

Multi tool use
Multi tool use












0















I'm working with java spring for the first time on a personal project and I can't seem to get any of the properties in application.properties to work correctly. I've simplified it down to this test case and it doesn't seem to be doing anything:



application.properties



logging.level.root=WARN


AppInitalizer.java:



import javax.servlet.Filter;

import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


@SpringBootApplication
@ConfigurationProperties
public class AppInitializer
extends AbstractAnnotationConfigDispatcherServletInitializer {

private static final Logger log = LoggerFactory.getLogger(AppInitializer.class);

@Override
protected Class<?> getRootConfigClasses() {
log.debug("This is a debug message");
log.error("This is an error message");
return new Class {};
}

@Override
protected Class<?> getServletConfigClasses() {
return new Class {};
}

@Override
protected String getServletMappings() {
return new String { "/" };
}

@Override
protected Filter getServletFilters() {
return new Filter {};
}
}


Log after deploy:



20:08:26.113 [http-nio-8080-exec-32] DEBUG AppInitializer - This is a debug message
20:08:26.114 [http-nio-8080-exec-32] ERROR AppInitializer - This is an error message


The two files are deployed to the same directory at the root of the classpath.



Only the second log message should be showing but I can't take care of the first.



Relevant ivy.xml config:



<!-- Spring Framework -->
<dependency org="org.springframework"
name="spring-webmvc" rev="5.0.9.RELEASE"/>
<!-- Logging -->
<dependency org="log4j" name="log4j" rev="1.2.17"/>


Edit: I switched out my logger to slf4j and still not luck.



Edit2: Added dependencies



Edit3: I was looking through he log and found this:



10:28:22.628 [http-nio-8080-exec-114] INFO org.springframework.web.context.ContextLoader - Root WebApplicationContext: initialization started
10:28:22.634 [http-nio-8080-exec-114] DEBUG org.springframework.web.context.support.StandardServletEnvironment - Adding PropertySource 'servletConfigInitParams' with lowest search precedence
10:28:22.634 [http-nio-8080-exec-114] DEBUG org.springframework.web.context.support.StandardServletEnvironment - Adding PropertySource 'servletContextInitParams' with lowest search precedence
10:28:22.636 [http-nio-8080-exec-114] DEBUG org.springframework.web.context.support.StandardServletEnvironment - Adding PropertySource 'jndiProperties' with lowest search precedence
10:28:22.636 [http-nio-8080-exec-114] DEBUG org.springframework.web.context.support.StandardServletEnvironment - Adding PropertySource 'systemProperties' with lowest search precedence
10:28:22.636 [http-nio-8080-exec-114] DEBUG org.springframework.web.context.support.StandardServletEnvironment - Adding PropertySource 'systemEnvironment' with lowest search precedence
10:28:22.636 [http-nio-8080-exec-114] DEBUG org.springframework.web.context.support.StandardServletEnvironment - Initialized StandardServletEnvironment with PropertySources [StubPropertySource@36449077 {name='servletConfigInitParams', properties=java.lang.Object@24214aae}, StubPropertySource@1983551321 {name='servletContextInitParams', properties=java.lang.Object@6e836355}, JndiPropertySource@219519027 {name='jndiProperties', properties=org.springframework.jndi.JndiLocatorDelegate@234fc705}, MapPropertySource@23923818 {name='systemProperties', properties={awt.toolkit=sun.awt.X11.XToolkit, java.specification.version=10, file.encoding.pkg=sun.io, sun.cpu.isalist=, sun.jnu.encoding=UTF-8, java.class.path=/usr/share/tomcat8/bin/bootstrap.jar:/usr/share/tomcat8/bin/tomcat-juli.jar, java.vm.vendor=Oracle Corporation, sun.arch.data.model=64, java.vendor.url=http://java.oracle.com/, catalina.useNaming=true, user.timezone=America/Los_Angeles, os.name=Linux, java.vm.specification.version=10, sun.java.launcher=SUN_STANDARD, user.country=US, sun.boot.library.path=/usr/lib/jvm/java-11-openjdk-amd64/lib, sun.java.command=org.apache.catalina.startup.Bootstrap start, jdk.debug=release, sun.cpu.endian=little, user.home=/var/lib/tomcat8, user.language=en, java.specification.vendor=Oracle Corporation, java.naming.factory.url.pkgs=org.apache.naming, java.version.date=2018-07-17, java.home=/usr/lib/jvm/java-11-openjdk-amd64, ignore.endorsed.dirs=, file.separator=/, java.vm.compressedOopsMode=32-bit, line.separator=
10:28:22.639 [http-nio-8080-exec-114] DEBUG org.springframework.web.context.support.StandardServletEnvironment - Replacing PropertySource 'servletContextInitParams' with 'servletContextInitParams'
10:28:22.639 [http-nio-8080-exec-114] INFO org.springframework.web.context.support.AnnotationConfigWebApplicationContext - Refreshing Root WebApplicationContext: startup date [Tue Jan 15 10:28:22 PST 2019]; root of context hierarchy


None of the property sources seem to be loading from the classpath which is where I have the application.properties.










share|improve this question

























  • I would suggest you to directly run your AppInitializer without creating a WAR and deploying it. SpringBoot comes with integrated Tomcat/Jetty which will be ready to use. In that way, you can debug your issue more easily

    – Shyam Baitmangalkar
    Jan 2 at 4:51











  • Can you give an example on how to do that? I'm not using an IDE, maven, or gradle. The docs say I can run it from a jar but it doesn't say what the layout of that jar should be.

    – user2752635
    Jan 2 at 16:44
















0















I'm working with java spring for the first time on a personal project and I can't seem to get any of the properties in application.properties to work correctly. I've simplified it down to this test case and it doesn't seem to be doing anything:



application.properties



logging.level.root=WARN


AppInitalizer.java:



import javax.servlet.Filter;

import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


@SpringBootApplication
@ConfigurationProperties
public class AppInitializer
extends AbstractAnnotationConfigDispatcherServletInitializer {

private static final Logger log = LoggerFactory.getLogger(AppInitializer.class);

@Override
protected Class<?> getRootConfigClasses() {
log.debug("This is a debug message");
log.error("This is an error message");
return new Class {};
}

@Override
protected Class<?> getServletConfigClasses() {
return new Class {};
}

@Override
protected String getServletMappings() {
return new String { "/" };
}

@Override
protected Filter getServletFilters() {
return new Filter {};
}
}


Log after deploy:



20:08:26.113 [http-nio-8080-exec-32] DEBUG AppInitializer - This is a debug message
20:08:26.114 [http-nio-8080-exec-32] ERROR AppInitializer - This is an error message


The two files are deployed to the same directory at the root of the classpath.



Only the second log message should be showing but I can't take care of the first.



Relevant ivy.xml config:



<!-- Spring Framework -->
<dependency org="org.springframework"
name="spring-webmvc" rev="5.0.9.RELEASE"/>
<!-- Logging -->
<dependency org="log4j" name="log4j" rev="1.2.17"/>


Edit: I switched out my logger to slf4j and still not luck.



Edit2: Added dependencies



Edit3: I was looking through he log and found this:



10:28:22.628 [http-nio-8080-exec-114] INFO org.springframework.web.context.ContextLoader - Root WebApplicationContext: initialization started
10:28:22.634 [http-nio-8080-exec-114] DEBUG org.springframework.web.context.support.StandardServletEnvironment - Adding PropertySource 'servletConfigInitParams' with lowest search precedence
10:28:22.634 [http-nio-8080-exec-114] DEBUG org.springframework.web.context.support.StandardServletEnvironment - Adding PropertySource 'servletContextInitParams' with lowest search precedence
10:28:22.636 [http-nio-8080-exec-114] DEBUG org.springframework.web.context.support.StandardServletEnvironment - Adding PropertySource 'jndiProperties' with lowest search precedence
10:28:22.636 [http-nio-8080-exec-114] DEBUG org.springframework.web.context.support.StandardServletEnvironment - Adding PropertySource 'systemProperties' with lowest search precedence
10:28:22.636 [http-nio-8080-exec-114] DEBUG org.springframework.web.context.support.StandardServletEnvironment - Adding PropertySource 'systemEnvironment' with lowest search precedence
10:28:22.636 [http-nio-8080-exec-114] DEBUG org.springframework.web.context.support.StandardServletEnvironment - Initialized StandardServletEnvironment with PropertySources [StubPropertySource@36449077 {name='servletConfigInitParams', properties=java.lang.Object@24214aae}, StubPropertySource@1983551321 {name='servletContextInitParams', properties=java.lang.Object@6e836355}, JndiPropertySource@219519027 {name='jndiProperties', properties=org.springframework.jndi.JndiLocatorDelegate@234fc705}, MapPropertySource@23923818 {name='systemProperties', properties={awt.toolkit=sun.awt.X11.XToolkit, java.specification.version=10, file.encoding.pkg=sun.io, sun.cpu.isalist=, sun.jnu.encoding=UTF-8, java.class.path=/usr/share/tomcat8/bin/bootstrap.jar:/usr/share/tomcat8/bin/tomcat-juli.jar, java.vm.vendor=Oracle Corporation, sun.arch.data.model=64, java.vendor.url=http://java.oracle.com/, catalina.useNaming=true, user.timezone=America/Los_Angeles, os.name=Linux, java.vm.specification.version=10, sun.java.launcher=SUN_STANDARD, user.country=US, sun.boot.library.path=/usr/lib/jvm/java-11-openjdk-amd64/lib, sun.java.command=org.apache.catalina.startup.Bootstrap start, jdk.debug=release, sun.cpu.endian=little, user.home=/var/lib/tomcat8, user.language=en, java.specification.vendor=Oracle Corporation, java.naming.factory.url.pkgs=org.apache.naming, java.version.date=2018-07-17, java.home=/usr/lib/jvm/java-11-openjdk-amd64, ignore.endorsed.dirs=, file.separator=/, java.vm.compressedOopsMode=32-bit, line.separator=
10:28:22.639 [http-nio-8080-exec-114] DEBUG org.springframework.web.context.support.StandardServletEnvironment - Replacing PropertySource 'servletContextInitParams' with 'servletContextInitParams'
10:28:22.639 [http-nio-8080-exec-114] INFO org.springframework.web.context.support.AnnotationConfigWebApplicationContext - Refreshing Root WebApplicationContext: startup date [Tue Jan 15 10:28:22 PST 2019]; root of context hierarchy


None of the property sources seem to be loading from the classpath which is where I have the application.properties.










share|improve this question

























  • I would suggest you to directly run your AppInitializer without creating a WAR and deploying it. SpringBoot comes with integrated Tomcat/Jetty which will be ready to use. In that way, you can debug your issue more easily

    – Shyam Baitmangalkar
    Jan 2 at 4:51











  • Can you give an example on how to do that? I'm not using an IDE, maven, or gradle. The docs say I can run it from a jar but it doesn't say what the layout of that jar should be.

    – user2752635
    Jan 2 at 16:44














0












0








0








I'm working with java spring for the first time on a personal project and I can't seem to get any of the properties in application.properties to work correctly. I've simplified it down to this test case and it doesn't seem to be doing anything:



application.properties



logging.level.root=WARN


AppInitalizer.java:



import javax.servlet.Filter;

import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


@SpringBootApplication
@ConfigurationProperties
public class AppInitializer
extends AbstractAnnotationConfigDispatcherServletInitializer {

private static final Logger log = LoggerFactory.getLogger(AppInitializer.class);

@Override
protected Class<?> getRootConfigClasses() {
log.debug("This is a debug message");
log.error("This is an error message");
return new Class {};
}

@Override
protected Class<?> getServletConfigClasses() {
return new Class {};
}

@Override
protected String getServletMappings() {
return new String { "/" };
}

@Override
protected Filter getServletFilters() {
return new Filter {};
}
}


Log after deploy:



20:08:26.113 [http-nio-8080-exec-32] DEBUG AppInitializer - This is a debug message
20:08:26.114 [http-nio-8080-exec-32] ERROR AppInitializer - This is an error message


The two files are deployed to the same directory at the root of the classpath.



Only the second log message should be showing but I can't take care of the first.



Relevant ivy.xml config:



<!-- Spring Framework -->
<dependency org="org.springframework"
name="spring-webmvc" rev="5.0.9.RELEASE"/>
<!-- Logging -->
<dependency org="log4j" name="log4j" rev="1.2.17"/>


Edit: I switched out my logger to slf4j and still not luck.



Edit2: Added dependencies



Edit3: I was looking through he log and found this:



10:28:22.628 [http-nio-8080-exec-114] INFO org.springframework.web.context.ContextLoader - Root WebApplicationContext: initialization started
10:28:22.634 [http-nio-8080-exec-114] DEBUG org.springframework.web.context.support.StandardServletEnvironment - Adding PropertySource 'servletConfigInitParams' with lowest search precedence
10:28:22.634 [http-nio-8080-exec-114] DEBUG org.springframework.web.context.support.StandardServletEnvironment - Adding PropertySource 'servletContextInitParams' with lowest search precedence
10:28:22.636 [http-nio-8080-exec-114] DEBUG org.springframework.web.context.support.StandardServletEnvironment - Adding PropertySource 'jndiProperties' with lowest search precedence
10:28:22.636 [http-nio-8080-exec-114] DEBUG org.springframework.web.context.support.StandardServletEnvironment - Adding PropertySource 'systemProperties' with lowest search precedence
10:28:22.636 [http-nio-8080-exec-114] DEBUG org.springframework.web.context.support.StandardServletEnvironment - Adding PropertySource 'systemEnvironment' with lowest search precedence
10:28:22.636 [http-nio-8080-exec-114] DEBUG org.springframework.web.context.support.StandardServletEnvironment - Initialized StandardServletEnvironment with PropertySources [StubPropertySource@36449077 {name='servletConfigInitParams', properties=java.lang.Object@24214aae}, StubPropertySource@1983551321 {name='servletContextInitParams', properties=java.lang.Object@6e836355}, JndiPropertySource@219519027 {name='jndiProperties', properties=org.springframework.jndi.JndiLocatorDelegate@234fc705}, MapPropertySource@23923818 {name='systemProperties', properties={awt.toolkit=sun.awt.X11.XToolkit, java.specification.version=10, file.encoding.pkg=sun.io, sun.cpu.isalist=, sun.jnu.encoding=UTF-8, java.class.path=/usr/share/tomcat8/bin/bootstrap.jar:/usr/share/tomcat8/bin/tomcat-juli.jar, java.vm.vendor=Oracle Corporation, sun.arch.data.model=64, java.vendor.url=http://java.oracle.com/, catalina.useNaming=true, user.timezone=America/Los_Angeles, os.name=Linux, java.vm.specification.version=10, sun.java.launcher=SUN_STANDARD, user.country=US, sun.boot.library.path=/usr/lib/jvm/java-11-openjdk-amd64/lib, sun.java.command=org.apache.catalina.startup.Bootstrap start, jdk.debug=release, sun.cpu.endian=little, user.home=/var/lib/tomcat8, user.language=en, java.specification.vendor=Oracle Corporation, java.naming.factory.url.pkgs=org.apache.naming, java.version.date=2018-07-17, java.home=/usr/lib/jvm/java-11-openjdk-amd64, ignore.endorsed.dirs=, file.separator=/, java.vm.compressedOopsMode=32-bit, line.separator=
10:28:22.639 [http-nio-8080-exec-114] DEBUG org.springframework.web.context.support.StandardServletEnvironment - Replacing PropertySource 'servletContextInitParams' with 'servletContextInitParams'
10:28:22.639 [http-nio-8080-exec-114] INFO org.springframework.web.context.support.AnnotationConfigWebApplicationContext - Refreshing Root WebApplicationContext: startup date [Tue Jan 15 10:28:22 PST 2019]; root of context hierarchy


None of the property sources seem to be loading from the classpath which is where I have the application.properties.










share|improve this question
















I'm working with java spring for the first time on a personal project and I can't seem to get any of the properties in application.properties to work correctly. I've simplified it down to this test case and it doesn't seem to be doing anything:



application.properties



logging.level.root=WARN


AppInitalizer.java:



import javax.servlet.Filter;

import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


@SpringBootApplication
@ConfigurationProperties
public class AppInitializer
extends AbstractAnnotationConfigDispatcherServletInitializer {

private static final Logger log = LoggerFactory.getLogger(AppInitializer.class);

@Override
protected Class<?> getRootConfigClasses() {
log.debug("This is a debug message");
log.error("This is an error message");
return new Class {};
}

@Override
protected Class<?> getServletConfigClasses() {
return new Class {};
}

@Override
protected String getServletMappings() {
return new String { "/" };
}

@Override
protected Filter getServletFilters() {
return new Filter {};
}
}


Log after deploy:



20:08:26.113 [http-nio-8080-exec-32] DEBUG AppInitializer - This is a debug message
20:08:26.114 [http-nio-8080-exec-32] ERROR AppInitializer - This is an error message


The two files are deployed to the same directory at the root of the classpath.



Only the second log message should be showing but I can't take care of the first.



Relevant ivy.xml config:



<!-- Spring Framework -->
<dependency org="org.springframework"
name="spring-webmvc" rev="5.0.9.RELEASE"/>
<!-- Logging -->
<dependency org="log4j" name="log4j" rev="1.2.17"/>


Edit: I switched out my logger to slf4j and still not luck.



Edit2: Added dependencies



Edit3: I was looking through he log and found this:



10:28:22.628 [http-nio-8080-exec-114] INFO org.springframework.web.context.ContextLoader - Root WebApplicationContext: initialization started
10:28:22.634 [http-nio-8080-exec-114] DEBUG org.springframework.web.context.support.StandardServletEnvironment - Adding PropertySource 'servletConfigInitParams' with lowest search precedence
10:28:22.634 [http-nio-8080-exec-114] DEBUG org.springframework.web.context.support.StandardServletEnvironment - Adding PropertySource 'servletContextInitParams' with lowest search precedence
10:28:22.636 [http-nio-8080-exec-114] DEBUG org.springframework.web.context.support.StandardServletEnvironment - Adding PropertySource 'jndiProperties' with lowest search precedence
10:28:22.636 [http-nio-8080-exec-114] DEBUG org.springframework.web.context.support.StandardServletEnvironment - Adding PropertySource 'systemProperties' with lowest search precedence
10:28:22.636 [http-nio-8080-exec-114] DEBUG org.springframework.web.context.support.StandardServletEnvironment - Adding PropertySource 'systemEnvironment' with lowest search precedence
10:28:22.636 [http-nio-8080-exec-114] DEBUG org.springframework.web.context.support.StandardServletEnvironment - Initialized StandardServletEnvironment with PropertySources [StubPropertySource@36449077 {name='servletConfigInitParams', properties=java.lang.Object@24214aae}, StubPropertySource@1983551321 {name='servletContextInitParams', properties=java.lang.Object@6e836355}, JndiPropertySource@219519027 {name='jndiProperties', properties=org.springframework.jndi.JndiLocatorDelegate@234fc705}, MapPropertySource@23923818 {name='systemProperties', properties={awt.toolkit=sun.awt.X11.XToolkit, java.specification.version=10, file.encoding.pkg=sun.io, sun.cpu.isalist=, sun.jnu.encoding=UTF-8, java.class.path=/usr/share/tomcat8/bin/bootstrap.jar:/usr/share/tomcat8/bin/tomcat-juli.jar, java.vm.vendor=Oracle Corporation, sun.arch.data.model=64, java.vendor.url=http://java.oracle.com/, catalina.useNaming=true, user.timezone=America/Los_Angeles, os.name=Linux, java.vm.specification.version=10, sun.java.launcher=SUN_STANDARD, user.country=US, sun.boot.library.path=/usr/lib/jvm/java-11-openjdk-amd64/lib, sun.java.command=org.apache.catalina.startup.Bootstrap start, jdk.debug=release, sun.cpu.endian=little, user.home=/var/lib/tomcat8, user.language=en, java.specification.vendor=Oracle Corporation, java.naming.factory.url.pkgs=org.apache.naming, java.version.date=2018-07-17, java.home=/usr/lib/jvm/java-11-openjdk-amd64, ignore.endorsed.dirs=, file.separator=/, java.vm.compressedOopsMode=32-bit, line.separator=
10:28:22.639 [http-nio-8080-exec-114] DEBUG org.springframework.web.context.support.StandardServletEnvironment - Replacing PropertySource 'servletContextInitParams' with 'servletContextInitParams'
10:28:22.639 [http-nio-8080-exec-114] INFO org.springframework.web.context.support.AnnotationConfigWebApplicationContext - Refreshing Root WebApplicationContext: startup date [Tue Jan 15 10:28:22 PST 2019]; root of context hierarchy


None of the property sources seem to be loading from the classpath which is where I have the application.properties.







java spring logging application.properties






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 15 at 18:45







user2752635

















asked Jan 2 at 4:18









user2752635user2752635

373316




373316













  • I would suggest you to directly run your AppInitializer without creating a WAR and deploying it. SpringBoot comes with integrated Tomcat/Jetty which will be ready to use. In that way, you can debug your issue more easily

    – Shyam Baitmangalkar
    Jan 2 at 4:51











  • Can you give an example on how to do that? I'm not using an IDE, maven, or gradle. The docs say I can run it from a jar but it doesn't say what the layout of that jar should be.

    – user2752635
    Jan 2 at 16:44



















  • I would suggest you to directly run your AppInitializer without creating a WAR and deploying it. SpringBoot comes with integrated Tomcat/Jetty which will be ready to use. In that way, you can debug your issue more easily

    – Shyam Baitmangalkar
    Jan 2 at 4:51











  • Can you give an example on how to do that? I'm not using an IDE, maven, or gradle. The docs say I can run it from a jar but it doesn't say what the layout of that jar should be.

    – user2752635
    Jan 2 at 16:44

















I would suggest you to directly run your AppInitializer without creating a WAR and deploying it. SpringBoot comes with integrated Tomcat/Jetty which will be ready to use. In that way, you can debug your issue more easily

– Shyam Baitmangalkar
Jan 2 at 4:51





I would suggest you to directly run your AppInitializer without creating a WAR and deploying it. SpringBoot comes with integrated Tomcat/Jetty which will be ready to use. In that way, you can debug your issue more easily

– Shyam Baitmangalkar
Jan 2 at 4:51













Can you give an example on how to do that? I'm not using an IDE, maven, or gradle. The docs say I can run it from a jar but it doesn't say what the layout of that jar should be.

– user2752635
Jan 2 at 16:44





Can you give an example on how to do that? I'm not using an IDE, maven, or gradle. The docs say I can run it from a jar but it doesn't say what the layout of that jar should be.

– user2752635
Jan 2 at 16:44












3 Answers
3






active

oldest

votes


















1














Please use slf4j.Logger over apache.commons.logging






share|improve this answer
























  • I switched it over and it still isn't working.

    – user2752635
    Jan 2 at 16:45



















1














Use slf4j's LoggerFactory instead of org.apache.commons.logging.LogFactory:



import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

private final Logger log = LoggerFactory.getLogger(this.getClass());


Or static logger:



private static final Logger log = LoggerFactory.getLogger(AppInitializer.class);





share|improve this answer
























  • I switched it over and it still isn't working.

    – user2752635
    Jan 2 at 16:45











  • @user2752635 can you show more relevant log configuration as in pom for example?

    – user7294900
    Jan 2 at 16:50











  • I'm not using maven. I have an ivy.xml file which ant uses to download dependencies. Did you want to see that?

    – user2752635
    Jan 2 at 17:17











  • @user2752635 yes,show log dependencies

    – user7294900
    Jan 3 at 5:26











  • I added the bootstrap and logging portion of the ivy.xml

    – user2752635
    Jan 3 at 16:52



















-1
















  1. Spring has also introduces the new @PropertySource annotation, as a convenient mechanism for adding property sources to the environment. This annotation is to be used in conjunction with Java based configuration and the @Configuration annotation:



    @Configuration
    @PropertySource("classpath:foo.properties")
    public class AppInitializer{
    //...
    }




  2. One other very useful way of registering a new properties file is using a placeholder to allow you to dynamically select the right file at runtime; for example:



    @PropertySource({
    "classpath:persistence-${envTarget:mysql}.properties"
    })




  3. You can use in XML, new properties files can be made accessible to Spring via the namespace element:






The foo.properties file should be placed under /src/main/resources so that it will be available on the classpath at runtime.






share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54001136%2ftomcat8-springboot-not-reading-application-properties%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    Please use slf4j.Logger over apache.commons.logging






    share|improve this answer
























    • I switched it over and it still isn't working.

      – user2752635
      Jan 2 at 16:45
















    1














    Please use slf4j.Logger over apache.commons.logging






    share|improve this answer
























    • I switched it over and it still isn't working.

      – user2752635
      Jan 2 at 16:45














    1












    1








    1







    Please use slf4j.Logger over apache.commons.logging






    share|improve this answer













    Please use slf4j.Logger over apache.commons.logging







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Jan 2 at 7:25









    shawonshawon

    11614




    11614













    • I switched it over and it still isn't working.

      – user2752635
      Jan 2 at 16:45



















    • I switched it over and it still isn't working.

      – user2752635
      Jan 2 at 16:45

















    I switched it over and it still isn't working.

    – user2752635
    Jan 2 at 16:45





    I switched it over and it still isn't working.

    – user2752635
    Jan 2 at 16:45













    1














    Use slf4j's LoggerFactory instead of org.apache.commons.logging.LogFactory:



    import org.slf4j.Logger;
    import org.slf4j.LoggerFactory;

    private final Logger log = LoggerFactory.getLogger(this.getClass());


    Or static logger:



    private static final Logger log = LoggerFactory.getLogger(AppInitializer.class);





    share|improve this answer
























    • I switched it over and it still isn't working.

      – user2752635
      Jan 2 at 16:45











    • @user2752635 can you show more relevant log configuration as in pom for example?

      – user7294900
      Jan 2 at 16:50











    • I'm not using maven. I have an ivy.xml file which ant uses to download dependencies. Did you want to see that?

      – user2752635
      Jan 2 at 17:17











    • @user2752635 yes,show log dependencies

      – user7294900
      Jan 3 at 5:26











    • I added the bootstrap and logging portion of the ivy.xml

      – user2752635
      Jan 3 at 16:52
















    1














    Use slf4j's LoggerFactory instead of org.apache.commons.logging.LogFactory:



    import org.slf4j.Logger;
    import org.slf4j.LoggerFactory;

    private final Logger log = LoggerFactory.getLogger(this.getClass());


    Or static logger:



    private static final Logger log = LoggerFactory.getLogger(AppInitializer.class);





    share|improve this answer
























    • I switched it over and it still isn't working.

      – user2752635
      Jan 2 at 16:45











    • @user2752635 can you show more relevant log configuration as in pom for example?

      – user7294900
      Jan 2 at 16:50











    • I'm not using maven. I have an ivy.xml file which ant uses to download dependencies. Did you want to see that?

      – user2752635
      Jan 2 at 17:17











    • @user2752635 yes,show log dependencies

      – user7294900
      Jan 3 at 5:26











    • I added the bootstrap and logging portion of the ivy.xml

      – user2752635
      Jan 3 at 16:52














    1












    1








    1







    Use slf4j's LoggerFactory instead of org.apache.commons.logging.LogFactory:



    import org.slf4j.Logger;
    import org.slf4j.LoggerFactory;

    private final Logger log = LoggerFactory.getLogger(this.getClass());


    Or static logger:



    private static final Logger log = LoggerFactory.getLogger(AppInitializer.class);





    share|improve this answer













    Use slf4j's LoggerFactory instead of org.apache.commons.logging.LogFactory:



    import org.slf4j.Logger;
    import org.slf4j.LoggerFactory;

    private final Logger log = LoggerFactory.getLogger(this.getClass());


    Or static logger:



    private static final Logger log = LoggerFactory.getLogger(AppInitializer.class);






    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Jan 2 at 7:36









    user7294900user7294900

    22.9k113362




    22.9k113362













    • I switched it over and it still isn't working.

      – user2752635
      Jan 2 at 16:45











    • @user2752635 can you show more relevant log configuration as in pom for example?

      – user7294900
      Jan 2 at 16:50











    • I'm not using maven. I have an ivy.xml file which ant uses to download dependencies. Did you want to see that?

      – user2752635
      Jan 2 at 17:17











    • @user2752635 yes,show log dependencies

      – user7294900
      Jan 3 at 5:26











    • I added the bootstrap and logging portion of the ivy.xml

      – user2752635
      Jan 3 at 16:52



















    • I switched it over and it still isn't working.

      – user2752635
      Jan 2 at 16:45











    • @user2752635 can you show more relevant log configuration as in pom for example?

      – user7294900
      Jan 2 at 16:50











    • I'm not using maven. I have an ivy.xml file which ant uses to download dependencies. Did you want to see that?

      – user2752635
      Jan 2 at 17:17











    • @user2752635 yes,show log dependencies

      – user7294900
      Jan 3 at 5:26











    • I added the bootstrap and logging portion of the ivy.xml

      – user2752635
      Jan 3 at 16:52

















    I switched it over and it still isn't working.

    – user2752635
    Jan 2 at 16:45





    I switched it over and it still isn't working.

    – user2752635
    Jan 2 at 16:45













    @user2752635 can you show more relevant log configuration as in pom for example?

    – user7294900
    Jan 2 at 16:50





    @user2752635 can you show more relevant log configuration as in pom for example?

    – user7294900
    Jan 2 at 16:50













    I'm not using maven. I have an ivy.xml file which ant uses to download dependencies. Did you want to see that?

    – user2752635
    Jan 2 at 17:17





    I'm not using maven. I have an ivy.xml file which ant uses to download dependencies. Did you want to see that?

    – user2752635
    Jan 2 at 17:17













    @user2752635 yes,show log dependencies

    – user7294900
    Jan 3 at 5:26





    @user2752635 yes,show log dependencies

    – user7294900
    Jan 3 at 5:26













    I added the bootstrap and logging portion of the ivy.xml

    – user2752635
    Jan 3 at 16:52





    I added the bootstrap and logging portion of the ivy.xml

    – user2752635
    Jan 3 at 16:52











    -1
















    1. Spring has also introduces the new @PropertySource annotation, as a convenient mechanism for adding property sources to the environment. This annotation is to be used in conjunction with Java based configuration and the @Configuration annotation:



      @Configuration
      @PropertySource("classpath:foo.properties")
      public class AppInitializer{
      //...
      }




    2. One other very useful way of registering a new properties file is using a placeholder to allow you to dynamically select the right file at runtime; for example:



      @PropertySource({
      "classpath:persistence-${envTarget:mysql}.properties"
      })




    3. You can use in XML, new properties files can be made accessible to Spring via the namespace element:






    The foo.properties file should be placed under /src/main/resources so that it will be available on the classpath at runtime.






    share|improve this answer




























      -1
















      1. Spring has also introduces the new @PropertySource annotation, as a convenient mechanism for adding property sources to the environment. This annotation is to be used in conjunction with Java based configuration and the @Configuration annotation:



        @Configuration
        @PropertySource("classpath:foo.properties")
        public class AppInitializer{
        //...
        }




      2. One other very useful way of registering a new properties file is using a placeholder to allow you to dynamically select the right file at runtime; for example:



        @PropertySource({
        "classpath:persistence-${envTarget:mysql}.properties"
        })




      3. You can use in XML, new properties files can be made accessible to Spring via the namespace element:






      The foo.properties file should be placed under /src/main/resources so that it will be available on the classpath at runtime.






      share|improve this answer


























        -1












        -1








        -1









        1. Spring has also introduces the new @PropertySource annotation, as a convenient mechanism for adding property sources to the environment. This annotation is to be used in conjunction with Java based configuration and the @Configuration annotation:



          @Configuration
          @PropertySource("classpath:foo.properties")
          public class AppInitializer{
          //...
          }




        2. One other very useful way of registering a new properties file is using a placeholder to allow you to dynamically select the right file at runtime; for example:



          @PropertySource({
          "classpath:persistence-${envTarget:mysql}.properties"
          })




        3. You can use in XML, new properties files can be made accessible to Spring via the namespace element:






        The foo.properties file should be placed under /src/main/resources so that it will be available on the classpath at runtime.






        share|improve this answer















        1. Spring has also introduces the new @PropertySource annotation, as a convenient mechanism for adding property sources to the environment. This annotation is to be used in conjunction with Java based configuration and the @Configuration annotation:



          @Configuration
          @PropertySource("classpath:foo.properties")
          public class AppInitializer{
          //...
          }




        2. One other very useful way of registering a new properties file is using a placeholder to allow you to dynamically select the right file at runtime; for example:



          @PropertySource({
          "classpath:persistence-${envTarget:mysql}.properties"
          })




        3. You can use in XML, new properties files can be made accessible to Spring via the namespace element:






        The foo.properties file should be placed under /src/main/resources so that it will be available on the classpath at runtime.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jan 2 at 6:01









        AvnishAvnish

        116




        116






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54001136%2ftomcat8-springboot-not-reading-application-properties%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            FUucYUG,Fyv,fL 2CxSgWmUDaX42RLszfKSa718rWrG7XDte06NH9m,a1Cb0RZ,HmK2eM
            aA,D5ey5Sx 0TEC,r,tYOgQ7E9,jASPnhiwUZvw

            Popular posts from this blog

            Monofisismo

            Angular Downloading a file using contenturl with Basic Authentication

            Olmecas