I have a Spring Controller that is not respecting the PropertySource attribute on the WebMvcConfigurerAdapter when ServletContextPropertyUtils.resolvePlaceholders is called.
Is there a way to get this to work? Other injected values (using @Value) seem to work fine.
@Configuration
@EnableScheduling
@EnableWebMvc
@ComponentScan(basePackages = "uk.co.mycompany.ui")
@PropertySource(value={"classpath:myapp.properties", "classpath:myapp-local-override.properties"}, ignoreResourceNotFound=true)
@Import({SecurityConfig.class})
public class AppConfig extends WebMvcConfigurerAdapter {
...
}
@Configuration
@Controller
@RequestMapping(value = "/api", headers = "Accept=application/xml")
public class ExternalController extends GenericUIController {
// This works fine.
@Value("${api.myvalue}")
String myvalue;
@RequestMapping(value = "")
public final void proxy(HttpServletRequest request, HttpServletResponse response) {
ServletContext context = request.getSession().getServletContext();
// BUG: This fails
// Resolve ${...} placeholders in the given text, replacing them with corresponding property values as resolved
// by getProperty(java.lang.String).
body = ServletContextPropertyUtils.resolvePlaceholders(body, context);
Aucun commentaire:
Enregistrer un commentaire