I am trying to use properties from a .properties
file, but it doesn\'t seem to work.
Here is my code:
@Service(\"ServiceFTP\")
@Transact
This Issue occurs if the application is unable to access the some_file_name.properties file.Make sure that the properties file is placed under resources folder in spring.
Trouble shooting Steps
1: Add the properties file under the resource folder.
2: If you don't have a resource folder. Create one by navigating new by Right click on the project new > Source Folder, name it as resource and place your properties file under it.
For annotation based Implementation
Add @PropertySource(ignoreResourceNotFound = true, value = "classpath:some_file_name.properties")
//Add it before using the place holder
Example:
Assignment1Controller.Java
@PropertySource(ignoreResourceNotFound = true, value = "classpath:assignment1.properties")
@RestController
public class Assignment1Controller {
// @Autowired
// Assignment1Services assignment1Services;
@Value("${app.title}")
private String appTitle;
@RequestMapping(value = "/hello")
public String getValues() {
return appTitle;
}
}
assignment1.properties
app.title=Learning Spring