开发者

https url in Spring ClassPathXmlApplicationContext

开发者 https://www.devze.com 2023-02-21 23:06 出处:网络
I used a Spring SingletonBeanFactoryLocator and the xml file passed to .getInstance() method contains this contents:

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

0

精彩评论

暂无评论...
验证码 换一张
取 消