【问题标题】:read from spring xml从spring xml中读取
【发布时间】:2020-10-20 19:27:48
【问题描述】:
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jms.activemq.ActiveMQAutoConfiguration;
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
import org.springframework.context.annotation.ImportResource;

@SpringBootApplication
@EnableAutoConfiguration(exclude={file1.class, file2.class})
@ImportResource(locations = {"classpath*:applicationContext.xml"})
public class Trans{

    public static void main(String[] args) {
        SpringApplication.run(Trans.class, args);
    }

}

当 jar 中存在 XML 时,它可以正常工作并读取 XML。我希望将 XML 从 jar 中删除到机器上的现有文件夹中。 执行此操作时,不会读取 XML。如何从机器文件系统而不是 jar 中读取 XML?

提前致谢!

【问题讨论】:

标签: java spring spring-boot


【解决方案1】:

试试这个:

@ImportResource(locations = {"file:/some/resource/path/applicationContext.xml"})

【讨论】:

  • 不确定我是否关注。你的applicationContext.xml 在哪里?
猜你喜欢
  • 2013-11-14
  • 1970-01-01
  • 2014-09-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多