properties-file

Spring Boot integration tests doesn't read properties files

岁酱吖の 提交于 2019-12-05 01:57:45
问题 I would like to create integration test in which Spring Boot will read a value from .properties file using @Value annotation. But every time I'm running test my assertion fails because Spring is unable to read the value: org.junit.ComparisonFailure: Expected :works! Actual :${test} My test: @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = {WebTests.ConfigurationClass.class, WebTests.ClassToTest.class}) public class WebTests { @Configuration @ActiveProfiles("test")

How would I specify a Hibernate “@Pattern” annotation using a regular expression from a .properties file or database

孤街浪徒 提交于 2019-12-04 23:35:37
问题 Situation : I would like to perform Hibernate Validation based upon user properties (to allow different validation rules for input based upon a user's account data) - I think it must be possible to use a .properties file to specify a particular regular expression, but I can't figure out what is wrong: My current method of specifying a validation regex pulls that regex from a constant in a particular interface file (to keep everything together) and plugs it in as a constant in an @Pattern()

Loading multiple properties files

北战南征 提交于 2019-12-04 16:56:14
问题 Is it possible to stack loaded properties in Java? For instance can I do: Properties properties = new Properties(); properties.load(new FileInputStream("file1.properties")); properties.load(new FileInputStream("file2.properties")); and access properties from both? 回答1: You can do this: Properties properties = new Properties(); properties.load(new FileInputStream("file1.properties")); Properties properties2 = new Properties(); properties2.load(new FileInputStream("file2.properties"));

Include A Properties File With A Jar File

試著忘記壹切 提交于 2019-12-04 12:26:34
问题 I've written a small application. I've put the database specific information in a properties file. db.url=jdbc:mysql://localhost:3306/librarydb db.user=root db.passwd=pas$w0rd When I build the application to get the executable jar file, the properties file gets included inside. The whole purpose of putting those information in a properties file is to allow the user to change those but this is making it impossible. How can I include a properties file with the jar file not in it? Kinda like you

access common property file inside bundle with osgi

自作多情 提交于 2019-12-04 11:47:50
I have an osgi application (in felix) with multiple bundles. There are some common property files in one bundle and the rest of the bundles need just use them. We use maven and spring osgi, the property files are in resouces like: <path to bundle>/src/main/resources/ common.properties engine.properties ... Maven builds them inside the bundle jar normally so they should be in an application classpath, but Spring has no access to them, this fails: <context:property-placeholder location="classpath:common.properties" /> (tried classpath*: and other combinations) I've read this and this Is it

PropertyPlaceholderConfigurer vs ReloadableResourceBundleMessageSource

你。 提交于 2019-12-04 09:47:27
Searching Google on how to configure property file in Spring 3 and I got many different answers. I found that ReloadableResourceBundleMessageSource and PropertyPlaceholderConfigurer can be used for getting properties from property files. Can somebody please explain the difference between these? PropertyPlaceholderConfigurer used for properties files to be used in the application context or inside the code with with @value. ResourceBundleMessageSource used for Internationalization & Localization (i18n) of messages you want to show to the user, within jsp direct, or from your code by wiring

How to get all properties files in a package and update the key values using java?

℡╲_俬逩灬. 提交于 2019-12-04 06:59:55
问题 I tried a lot, but was unable to find a solution. | |--src/main/resouces | |-updatePropertiesFile.java |-xyz_en_US.properties |-xyz_en_AF.properties |-xyz_en_AE.properties This is my project structure. I have a updatePropertiesFile class, to update a key for all the properties file. I have around 200 properties file. So what I need is that, I need to write a method to update a particular key in all these properties file. Manual change is not that practically. I need to write an application

How to append new data to existing data in properties file?

巧了我就是萌 提交于 2019-12-04 05:12:25
I am using following code for writing data to properties file public void WritePropertiesFile(String key, String data) { Properties configProperty = new Properties(); configProperty.setProperty(key, data); File file = new File("D:\\Helper.properties"); FileOutputStream fileOut = new FileOutputStream(file,true); configProperty.store(fileOut, "sample properties"); fileOut.close(); } I am calling the above method 3 times as follows: help.WritePropertiesFile("appwrite1","write1"); help.WritePropertiesFile("appwrite2","write2"); help.WritePropertiesFile("appwrite3","write3"); However, the data in

Spring Boot + Thymeleaf not finding message properties

走远了吗. 提交于 2019-12-04 03:56:55
问题 I am trying to create a web application using Spring Boot and Thymeleaf and am having trouble getting the template to use the messages defined in a properties file. Instead of the message defined in the properties file, it is instead showing ??form.welcome_en_GB?? The console isn't logging any errors. The project structure is like this ──┬ 🗁 src │ └─── 🗁 main │ ├─── 🗁 java │ │ └─── 🗁 com │ │ └─── 🗁 package │ │ ├─── 🗁 controller │ │ │ └─── FormController.java │ │ ├─── Application.java │ │ └───

Spring Boot default properties encoding change?

懵懂的女人 提交于 2019-12-04 01:44:31
问题 I am trying to find a way to set UTF-8 encoding for properties accessed via @Value annotation from application.property files in Spring boot. So far I have been successfully set encoding to my own properties sources by creating a bean: @Bean @Primary public PropertySourcesPlaceholderConfigurer placeholderConfigurer(){ PropertySourcesPlaceholderConfigurer configurer = new PropertySourcesPlaceholderConfigurer(); configurer.setLocation(new ClassPathResource("app.properties"); configurer