https url in Spring ClassPathXmlApplicationContext
I used a Spring SingletonBeanFactoryLocator and the xml file passed to .getInstance() method contains this contents:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans default-lazy-init="true">
<bean id="it.rules.bean.commands"
class="org.springframework.context.support.ClassPathXmlApplicationContext" >
<constructor-arg>
<list>
<value>https://aPathToFolder/commands.xml</value>
</list>
</constructor-arg>
</bean>
</beans>
I receive a 401 error caused, I think, because of the https URL.
Is there any way to use https URLs in a ClassPathXmlApplicationContext directly in Spring? Or is there a 开发者_JS百科best practice to do this?
I would say: ClassPathXmlApplicationContext
is designed class path related resources, not for http/https!
Standalone XML application context, taking the context definition files from the class path, interpreting plain paths as class path resource names that include the package path (e.g. "mypackage/myresource.txt"). Useful for test harnesses as well as for application contexts embedded within JARs.
From the Java Doc of ClassPathXmlApplicationContext
.
What you can try, is to exchange the ResourceLoader by one that is able to load the configuration file via HTTP(s).
@See public int loadBeanDefinitions(String location, Set<Resource> actualResources)
of class org.springframework.beans.factory.support.AbstractBeanDefinitionReader
精彩评论