How to externalize .property file from classpath? - websphere

Is there any way to keep struts ApplicationResource.property file outside of project directory and add location in Websphere jvm argument or custom property?
Property file contains the following info:-
Error.uname= ***
Error.pwd=xxx
It is configured in struts-config.xml file using message resources.
Any suggestions would be really helpful. Thanks in advance.

Related

Spring: How to access a txt file located outside the jar?

Currently, I am passing the environment specfic configs in a properties file outside the jar using -Dspring.config.location=/apps/conf/application-dev.properties. I also have properties file included in the jar named application.properties which has configs that don't change often. There's one config called nameFile:
nameFile=classpath:config/nameList.txt
And the actual nameList.txt is included in the jar under spring-app/src/main/resources/config/nameList.txt but I want to move the nameList.txt outside the jar.
What I've tried:
Changing it to nameFile =${auth.nameList} and added this to /apps/conf/application-dev.properties like:
auth.nameList=classpath:/apps/conf/nameList.txt
And I moved the nameList.txt file from the jar to /apps/conf/ location but the Spring application fails because it cannot find the txt file. How do I fix this? I want to move the nameList.txt to outside the jar.
Removed classpath:
auth.nameList=/apps/conf/nameList.txt
No luck!
When you provide a path, classpath will "tell" the JVM that the location is within the jar/war file. If you have the resource you need in an external location, you will need file instead.
auth.nameList=file:/apps/conf/nameList.txt

Spring boot starts even if start with nonexistent profile

I have spring boot application - server.jar with next structure:
-resources
-application.yaml
After the build, I create a folder with a name source. And put my jar to this folder. Also, I create start .bat file
-source
-server.jar
-start.bat
In start.but the file I write next:
java -Dspring.profiles.active="foofoofoo" -jar server.jar
pause
When I run start.bat my server starts with log:
The following profiles are active: foofoofoo
And use properties from application.yaml. I have not profile with name foofoofoo and I have not apllication-foofoofoo.yaml. Why? Why spring writes that it loads foofoofoo profile, load application.yaml and work?
It must crash because I start the application with the nonexistent profile!
Instead, I see a running application with another property! How can I process this?
When you start the application application.yml file in your resources directory is getting included anyway.
If you also have application-yourProfileName.yml in resources directory and add
--spring.profile.active=yourProfileName parameter,
then both property files are getting included, and NOTE that in this case application-yourProfileName.yml override the same properties in application.yml.
The profile can be used in more ways than just application's properties. It does not matter if you do not have application-your-profile.{properties, yml}. Loading profile does not mean loading properties file.

How to externalize i18n properties files in spring-boot applications

I’ve succeed to externalize my spring-boot configuration file (application.properties) in a config folder when I run my spring-boot application as a unix service with the help of the official spring documentation https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html
I have also some i18n messages.properties files in my src/main/resources that I would like to externalize in the same config folder but I failed to do it. I’ve tried a lot of things, like playing with spring.messages.basename but unfortunately, it doesn’t work.
I’m using the latest version of spring-boot, and use auto configure mode with the default i18n properties name messages.
What am I missing??? thanks for your help.
Just a few notes:
classpath:message - will always lookup embeded message_xxx files
classpath:/message and classpath:message are equivalent
file:message - will lookup jar's external current directory e.g. ./message_en.properties <- this is what you want
file:/message - you have to put your message files to root "/" to make it work
use notation file:config/message if you need to put in config folder together with your
./config/application.properties
I think you need a leading slash.
Try: spring.messages.basename=classpath:/config/messages
I think, resource bundle is default to classpath. So there's no need to append it. just go straight to your folder location from classpath.
Try this: **assuming your config is inside static folder
spring.messages.basename=static/config/messages

How to modify the Netbeans Application Configuration?

I have a Maven Netbeans Application I want to modify its configuration. What do I need to do to change startup parameters from the conf file like: default_options?
I have to manually do it but would like to make it part of the build process.
You will have to create a netbeans.conf file in your nbm-application project and point the nbm-maven-plugin to it's location - please see http://mojo.codehaus.org/nbm-maven/nbm-maven-plugin/cluster-app-mojo.html#etcConfFile
Create your own ProjectName.conf, for example from default ProjectName.conf file.
Next place it in nbproject folder.
And add to project.conf line like this:
app.conf=nbproject/ProjectName.conf
Support for Custom Configuration Files in NetBeans

Could not find fetcher.properties on classpath

I am working to implement RSS feed using the spring integration as mentioned in the article http://comdynamics.net/blog/295/spring-integration-rss-feed-reader/. However, when I run the application I am getting the following error:
Could not find fetcher.properties on classpath
Can you point me in the right direction?
Can you verify that you have the folder that contains this property file in the classpath of the project? You would have to look at .classpath file to verify this.
Ideally you would want to keep this file in a config folder and must be added to the classpath just like your source folder.
create an empty file named fetcher.properties on classpath. You don't have to add any entry to it.That will solve the problem

Resources