Spring无法使用@PropertySource找到classpath资源(Spring not able to find classpath resource with @PropertySource)
我在我的数据源配置文件中使用
@PropertySource
来获取位于类路径上的属性文件。 以下是我的项目结构。我相信我可以通过两种方式做到:
- 通过在
src
文件夹中创建一个包并将其添加到那里。 由于src
文件夹已经包含在Eclipse中的类路径中,所以下面的内容应该可以工作。@PropertySource({@PropertySource(“classpath:com / spring / property / general.properties”),@PropertySource(“classpath:com / spring / property / hibernate.properties”)})
- 第二种方法是创建一个
resources
文件夹并将其添加到类路径中,以下内容应该可以工作@PropertySource({@PropertySource(“classpath:general.properties”),@PropertySource(“classpath:hibernate.properties”)})
在我的情况下,两者都没有工作。 作为一名Java开发人员,这仍然让我感到困惑。 任何人都可以引导我朝着正确的方向前进。 另外我们如何在生产环境中为Spring配置classpath资源。
编辑 :我已经改变了我的项目结构,以包含属性文件在
src/java/resources
,我可以看到构建路径中的resources
文件夹。 仍然.properties
不会被春天发现。I am using
@PropertySource
in my datasource configuration file to get property files located on classpath. Below is my project structure.I believe I can do it in two ways:
- By creating a package in
src
folder and add them there. Assrc
folder is already included in the classpath in eclipse, following should work.@PropertySources({ @PropertySource("classpath: com/spring/property/general.properties"), @PropertySource("classpath: com/spring/property/hibernate.properties") })
- Second way is to create a
resources
folder and add it to the classpath and following should work@PropertySources({ @PropertySource("classpath: general.properties"), @PropertySource("classpath: hibernate.properties") })
In my case neither of the two is working. Being an intermediate java developer this still confuses me. Can anybody guide me in the right direction. And also how we can configure classpath resources for Spring in a production environment.
EDIT: I have changed my project structure to include properties file in
src/java/resources
and I can see theresources
folder in build path. Still.properties
are not found by spring.
原文:https://stackoverflow.com/questions/40232870
最满意答案
关闭这个问题回答(我有时是derp)
我没有使用触控板做过很多iOS的东西。 好像我期待两个手指滚动在模拟器上“滚动”。 它不是!
对于遇到此问题的其他人来说,这是个问题。
Closing this question as answered (I'm a derp sometimes)
I haven't done much iOS stuff using a trackpad. Seems like I was expecting two finger scrolling to "scroll" on the simulator. It does not!
A heads up for anyone else having this issue.
相关问答
更多-
UITableView没有滚动(UITableView has no scrolling)[2022-09-09]
我的清单在这种情况下: 是tableview scrollEnabled == YES? tableView.contentSize.width!= tableView.bounds.size.width && tableView.contentSize.height!= tableView.bounds.size.height; 界面方向是否正确? 在tableview中没有任何隐藏的UIView或子类。 My checklist in this case: is tableview scrollEnab ... -
自动滚屏行为位于UITableViewController功能中。 要禁用自动滚动,我发现两种方法: 使用UITableViewController替代UIViewController - 设置数据源和委托您自己。 覆盖viewWillAppear方法,不要调用[super viewWillAppear: animated] 使用这两种解决方案,您不仅可以禁用Autoscroll,还可以禁用Apple's类参考概述中描述的其他一些不错但不重要的功能: https://developer.apple.com/ ...
-
看起来你的cellForRowAtIndexPath方法使用userButtonState[indexPath.row]来确定是否更改boostButton的图像。 因此,您只需要修改您的pressedButtonInCell方法,为相关行设置userButtonState: func pressedButtonInCell(cell:BoostCell) { cell.boostButton.setImage(self.boostedButton, forState: UIControlState ...
-
我建议将QuizInfoCell创建为新的XIB文件。 按CMD + N. 选择“ User Interface子菜单。 创建一个新View并将其QuizInfoCell 在新的XIB中删除现有的View元素,而是拖放一个新的Table View Cell 。 通过拖放标签和imageView,以与以前相同的方式重新创建自定义UITableViewCell 最后给新的Cell一个名为QuizInfoCell的标识符,如下所示: 然后,您可以使用代码加载新的自定义UITableViewCell: - (UIT ...
-
自定义UITableViewCell在滚动时更改indexPath?(Custom UITableViewCell changing indexPath While Scrolling?)[2022-01-25]
当你在if(cell == nil)条件下创建一个单元格时,是否将单元格的reuseIdentifier赋值为“CalendarEventCell”? 我可以看到你的笔尖名称是CalendarEventCell,但我想你也需要设置 cell.reuseIdentifier = @"CalendarEventCell"; 如果不是,那么我不确定它是否可以使正确的单元出质。 另外,不知道customCellLabel引用了什么。 When you create a cell in if(cell==nil) c ... -
问题出在我的表格视图单元格的layoutSubviews 。 self.contentView.frame = CGRectMake(self.frame.origin.x, self.frame.origin.y, self.frame.size.width, cellHeight); 应该是: self.contentView.frame = CGRectMake(self.contentView.frame.origin.x, self.contentView.frame.origin.y, sel ...
-
复杂视图层次结构和Alpha混合将始终消除滚动性能。 您需要展平/简化视图层次结构,或者开始使用CoreGraphics技能。 如果您对查看混合程度感兴趣,请在仪器中运行(在设备上)“核心动画”模式,然后选中“颜色混合图层”复选框。 你想看到尽可能多的绿色,红色越深,混合越差。 Complex view hierarchies and alpha blending will always kill your scrolling performance. You need to either flatten/ ...
-
对于那些感兴趣的人,我找到了解决上一个问题的有效解决方案。 问题是,当选择样式为UITableViewCellSelectionStyleNone ,编辑模式下的红色复选标记无法正确显示。 解决方案是创建一个自定义UITableViewCell并ovverride一些方法。 我正在使用awakeFromNib因为我的单元格是通过xib创建的。 为了达到解决方案,我遵循了以下两个stackoverflow主题: 多选表-视图-细胞和无选择风格 UITableViewCell的知识对防止蓝色选择背景-WO-bo ...
-
制作自定义UITableViewCell - 现在UITableView不滚动(Made Custom UITableViewCell — Now UITableView Is Not Scrolling)[2023-09-05]
关闭这个问题回答(我有时是derp) 我没有使用触控板做过很多iOS的东西。 好像我期待两个手指滚动在模拟器上“滚动”。 它不是! 对于遇到此问题的其他人来说,这是个问题。 Closing this question as answered (I'm a derp sometimes) I haven't done much iOS stuff using a trackpad. Seems like I was expecting two finger scrolling to "scroll" on t ... -
带有自定义UITableViewCell的UITableView不显示单元格(UITableView with custom UITableViewCell not displaying cell)[2021-12-16]
我认为代码没有问题。 Apple现在提供了一个缩放模拟器,因此您可以通过以下方式检查设备输出5个不同的缩放模拟器。 而且你也可以检查你的分频器必须出现的真实设备,但是对于模拟器你只需要像下面那样100%改变模拟器比例。 I think there is not an issue with code. Apple now provide a scaled simulators so you can check the device output 5 different scaled simulator tha ...