我使用eclipse Plug-in项目向导(使用eclipse Helios)创建了两个OSGI包A和B.
在bundle BI的清单文件中添加了bundle A作为依赖项.此外,我已经在A中导出了包,因此它们对于B是可见的.我还在捆绑包A中有一个.properties文件,我希望它对bundle B可见.在bundle AI的build.properties窗格中指定了:
source.. = src/
bin.includes = META-INF/,\
.,\
bundle_A.properties
Run Code Online (Sandbox Code Playgroud)
现在在BI中尝试使用以下命令加载.properties文件:
private Properties loadProperties() {
Properties properties = new Properties();
InputStream istream = this.getClass().getClassLoader().getResourceAsStream(
"bundle_A.properties");
try {
properties.load(istream);
} catch (IOException e) {
logger.error("Properties file not found!", e);
}
return properties;
}
Run Code Online (Sandbox Code Playgroud)
但是这会产生一个nullpointer异常(在类路径中找不到该文件).
是否可以从bundle A导出资源(就像导出包时一样)或者以某种方式从B以另一种方式访问A中的文件(从bundle B访问bundle A的类加载器)?
我刚刚注意到,虽然来自a的大多数getter Bundle都有可能包含一个默认值,但是如果该特定bundle实例中不存在该键,getString则没有那种可能性,如果是这种情况则返回null.
关于为什么会有这样的想法以及是否有某种方法可以轻松解决这个问题(简单来说,我的意思是不必检查每个单独的值或扩展Bundle类).
例如,现在你只有这个:
bundle.getString("ITEM_TITLE");
Run Code Online (Sandbox Code Playgroud)
虽然我想这样做:
bundle.getString("ITEM_TITLE","Unknown Title");
Run Code Online (Sandbox Code Playgroud)
谢谢!
我已经拥有了所有的宝石,每次都有
rails trytry02
cd trytry02
bundle install
Run Code Online (Sandbox Code Playgroud)
要创建Gemfile.lock,从rubygems.org获取数据需要很长时间.但我注意到,如果我做了
rails g scaffold foo name:string
Run Code Online (Sandbox Code Playgroud)
在进行bundle安装之前,Gemfile.lock的创建速度非常快.有没有办法快速创建但不使用rails g scaffold?
我在github上分享了spree repo,我想在我的rails app的Gemfile中指定一个位于core主存储库子目录中的gem .
存储库的文件夹结构如下:
|~spree [git root]
| |-spree.gemspec [spree gem located here]
|~core
| |-spree_core.gemspec [spree_core gem located here]
Run Code Online (Sandbox Code Playgroud)
换句话说,我想沿着这些方向做点什么:
gem 'spree-core', :git => 'git://github.com/spree/spree.git'
Run Code Online (Sandbox Code Playgroud)
问题是,当我尝试时,我收到以下错误消息bundle install:
在git://github.com/spree/spree.git(在master中)找不到gem'spree-core(> = 0)'.Source不包含任何版本的'spree-core(> = 0)'
我是android的新手,我面临以下问题.我正在为Android 2和3开发,这就是我使用片段的原因.然而,为了使应用程序在Android 2设备上运行,我导入android.support.v4.app.ListFragment.当屏幕方向改变时,我需要在ListFragment中保持选择.我正在重写onSaveInstanceState()方法并将int放入bundle中.旋转屏幕时,将调用此方法并将int添加到包中.但是,在onActivityCreated()调用时,其bundle为null.我遵循Android网站上提供的示例:http://developer.android.com/reference/android/app/Fragment.html,但如上所述 - 在onSaveInstanceState()调用之后,bundle in onActivityCreated()仍为null.
这是代码:
import android.support.v4.app.ListFragment;
public class VisitsHomeFragment extends ListFragment {
private int selectedPosition = -1;
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
if (savedInstanceState != null) {
if (savedInstanceState.containsKey("SELECTED_POSITION")) {
selectedPosition = savedInstanceState.getInt("SELECTED_POSITION");
}
}
}
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putInt("SELECTED_POSITION", selectedPosition);
}
}
Run Code Online (Sandbox Code Playgroud)
我很感激这个问题的任何帮助.
android bundle screen-orientation android-fragments android-3.0-honeycomb
我尝试与同一捆绑的两个实体经理一起工作.我的配置是这样的:
orm:
default_entity_manager: default
entity_managers:
electra:
connection: electra
mappings:
XXDemoBundle: ~
default:
connection: default
mappings:
XXDemoBundle: ~
Run Code Online (Sandbox Code Playgroud)
有没有办法告诉哪个entites属于哪个实体经理?如果我想使用不属于默认实体管理器的表,它现在崩溃了.
谢谢
这是我的连接配置:
doctrine:
dbal:
default_connection: default
connections:
default:
dbname: old_project
user: root
password: 123123
host: 1.1.1.1
port: 1
electra:
dbname: electra
user: root
password: 123123
host: 2.2.2.2
port: 2
orm:
default_entity_manager: electra
entity_managers:
electra:
connection: electra
mappings:
XXDemoBundle: ~
default:
connection: default
mappings:
XXDemoBundle: ~
Run Code Online (Sandbox Code Playgroud) 为什么不是第二个命令
$ bundle install
Run Code Online (Sandbox Code Playgroud)
不需要
--without production
Run Code Online (Sandbox Code Playgroud)
(因为这是它在教程中的用法,所以我认为它是正确的)不需要它背后发生了什么/推理?
来自http://ruby.railstutorial.org/chapters/a-demo-app#sec-demo_users_resource
$ bundle install --without production
$ bundle update
$ bundle install
Run Code Online (Sandbox Code Playgroud) 我有一个javascript包,我只想在测试时包含,而不是在代码部署到生产时.
我添加了一个名为的属性IsEnabledTestingFeatures.在BundleConfig.cs文件中,我这样访问它:
if(Properties.Settings.Default.IsEnabledTestingFeatures) {
bundles.Add(new ScriptBundle("~/bundles/testing").Include("~/Scripts/set-date.js"));
}
Run Code Online (Sandbox Code Playgroud)
这工作正常.
现在,如果此属性设置为true ,我只想在我的页面中包含该包.
我尝试了以下,但编译器抱怨它无法找到Default命名空间:
@{
if( [PROJECT NAMESPACE].Properties.Default.IsEnabledTestingFeatures)
{
@Scripts.Render("~/bundles/testing")
}
}
Run Code Online (Sandbox Code Playgroud)
我试图找到如何Scripts.Render从Controller本身访问功能,但一直没有成功.
我更喜欢在视图中添加bundle,但是会通过Controller添加它.
不能为我的生活摆脱这个错误 - 一直在尝试一天无济于事.gem pristine --all什么也没做,也没有删除和重新安装捆绑.其他人遇到这个,知道该怎么办?我会在外面感谢答案!
完整的错误在这里:
警告:运行
gem pristine --all以重新生成已安装的gem规范(如果使用bundle -path,则删除然后重新安装bundle)将提高Spring的启动性能.
每次运行Rails或Rails控制台时都会发生这种情况.
在发布之前,候选角度提供了捆绑文件.由于发布候选版本没有更多的捆绑文件.包括angular2和rxjs我的应用程序现在可以加载超过7秒的671个请求.这削弱了发展.
有谁知道如何捆绑angular和rxjs并将它们包含在system.config中?