java - add directory to classpath in runtime -


In my current spring project, when I run an application, a directory is created on the user's home directory where I Files in the configuration (* .properties file) In my code, I see this file like this:

  private string getFilename () {System.getProperty return ("user.home" ) + File.Sseparator + ". Webapp" + File .separator + "webapp.preferences"; }  

which allows me to run the application in any operating system without changing the code. I need to add this directory to the application's pathpad, to allow me to use the properties stored in the file to use annotation PropertySource , either from the Entrepreneur class, the method getproperty or Value annotation.

I am using spring-boot, so the starting point for the application is that:

  @Controller @ConceptJapaRepositories @ContentAutoConfiguration @ComponentScan (value = "com .spring ") public class application {public static zero main (string [] args throws exceptions {SpringApplication.run (application class, args); }}  

I have also to store configurations that handle spring from Web.xml and despatcher-config.xml with XML files near webface installer, webpix config and dispatch config.

UPDATE

To tell any person whether it is possible and possible to complete?

UPDATE

After sugestions in comments, I add this to my project in the bean:

  @bean constant Property Source Placeholder Configuror Property () throws exceptions {PropertySourcesPlaceholderConfigurer propertyConfigurer = new PropertySourcesPlaceholderConfigurer (); String file name = System.getProperty ("user.home") + file. Separator + ".weep" + file. Separator + "webapp.preferences"; File file = new file (file name); If (file.exists ()) propertyConfigurer.setLocation (new FileSystemResource (filename)); Else {if (file.mkdir ()) {FileOutputStream fos = new FileOutputStream (filename); Fos.close (); PropertyConfigurer.setLocation (new FileSystemResource (filename)); }} Return Property Configurator; }  

and try to use it in your pojo class:

  @Input (label = "Titulo") @Property (key = "geral .titulo ") @ value (value =" $ {geral.titulo} ") private string title;  

But when I create a new example of this class, the field does not get the value indicated by annotation. Am i wrong I confirm the file and the properties present in it exist.


Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -