Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 517 Vote(s) - 3.56 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Spring Boot app: Not picking up application.properties?

#11
I was having this problem. If I did a "Rebuild" from IntelliJ it would copy the application.properties from my src/test/reources folder to my target/test-classes and things would work. But, if I built from Maven, it would disappear from the target/test-classes folder and then the tests would fail when run by maven because it couldn't find the application.properties file. Low and behold, after much back and forth, I realized that my folder was named incorrectly (above is not a typo). I had "src/test/reources/application.properties" instead of "src/test/resources/application.properties". What a pain to spot that. The above answers helped me hone in on it and finally notice the typo. Was not as obvious as one might think. Watch out for that.
Reply

#12
In my case, I had an Encryption Utility class and I was loading public and private keys from the base properties file.

adding **@Component** annotation worked for me.

@Component
public class AESEncryption {

private static String BASE64_ENCODED_PUBLIC_KEY;
private static String BASE64_ENCODED_PRIVATE_KEY;

public AESEncryption(@Value("${BASE64_ENCODED_PUBLIC_KEY}") String BASE64_ENCODED_PUBLIC_KEY,
@Value("${BASE64_ENCODED_PRIVATE_KEY}") String BASE64_ENCODED_PRIVATE_KEY) {
this.BASE64_ENCODED_PUBLIC_KEY = BASE64_ENCODED_PUBLIC_KEY;
this.BASE64_ENCODED_PRIVATE_KEY = BASE64_ENCODED_PRIVATE_KEY;
}
}
Reply

#13
Your can always specify where you want spring to look for properties file like so in your pom.xml build section.

<resources>
<resource>
<directory>src/main/assembly</directory>
<filtering>true</filtering>
</resource>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
<resource>
<directory>src/main/config</directory>
<filtering>true</filtering>
</resource>
</resources>
Reply

#14
Declare the PropertySourcesPlaceholderConfigurer in your @Configuration class.

@Bean
public static PropertySourcesPlaceholderConfigurer propertyPlaceholderConfigurer() {

return new PropertySourcesPlaceholderConfigurer();
}

And your property resource path with the proper annotation.

@PropertySource("classpath:your.properties")
Reply

#15
Try renaming the application properties file and try it. It should detect and compile. It worked for me.
Reply

#16
After spending hours and hours this worked!

**Problem**: Springboot 2.X.X ignores application.properties/application.yml and always start the tomcat on default port 8080.

**Root cause**: It is weird from Spring boot 2.x.x and seen in only some machines. Spring docs does not have a concept like this. This is a custom problem.

**Solution**: Provide spring.config.location as classpath:application.properties ( usually we use this practice for external config files but for this issue this works).
Let me know if it also works for you.
Reply

#17

In My case, it was logback-spring.xml. After removing spring in logback filename, it started working.
Reply

#18
In my case, the resource folder was not registered as a resource. I use IntelliJ, so I went to the module settings section, selected the resources folder and then clicked on resource on the upper part of the window. it started taking the application.properties file after that.
Reply

#19
For me, every time I built just with IntelliJ build, and not with maven command.
finally I found that `application.properties` that located in /target folder is not updated.

Only when I build using maven (even without clean), changes reflected to target folder.
Reply

#20
I had the same kind of problem on IntelliJ, I could see the variables wired in the file, but it would not wire it when I launched my SpringBoot app.

I resolved the problem by deleting the `.idea` folder and invalidating cache + restart
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through