ClasspathXMLApplicationContext在spring工作

时间:2016-07-20 10:03:05

标签: spring

我是Spring的新手,我正在尝试理解语句" ClassPathXMLApplication上下文在类路径"中的所有jar中搜索xml。

所以在应用程序中

CATransaction.begin()
CATransaction.setCompletionBlock {
    let cell = self.tableView(self.tableView, cellForRowAtIndexPath: self.editingIndexPath!) as! TallyCell
    cell.titleTextField.hidden = false
    cell.titleTextField.becomeFirstResponder()
}

tableView.beginUpdates()
tallies.append("Example")
tableView.insertRowsAtIndexPaths([editingIndexPath!], withRowAnimation: .Left)
tableView.endUpdates()

CATransaction.commit()

是否会在myBeans.xml的所有相关jar中搜索?

2 个答案:

答案 0 :(得分:1)

它会工作,但是你没有正确的文件路径,因为它在类路径的jar中,你必须给出这样的东西

{{1}}

希望这会有所帮助。

答案 1 :(得分:0)

以下是了解如何使用构造函数传递应用程序bean上下文的链接。

http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/context/support/ClassPathXmlApplicationContext.html

ApplicationContext context = new ClassPathXmlApplicationContext("myBeans.xml"); 
如果放在src / resources / myBeans.xml下,

工作正常,因为

类路径根 WEB-INF / classes src / main / resources src / main / java 一起去那里