使用PropertyPlaceholderConfigurer和PropertySource(Using both PropertyPlaceholderConfigurer and PropertySource)
我在这里遇到了一些困难。 我正在设计一个实用程序,我需要我的Spring上下文将命令行参数作为属性来处理。 这很容易完成:
if (args != null && args.length > 0) { PropertySource<?> ps = new SimpleCommandLinePropertySource(args); ctx.getEnvironment().getPropertySources().addFirst(ps); }
我遇到的问题是下一步:为了符合我的企业框架,我必须设置一个他们提供的
PropertyPlaceholderConfigurer
1 。 也很容易完成。@Bean public PropertyPlaceholderConfigurer propertyPlaceholderConfigurer() { return new MyPropertyPlaceholderConfigurer(); }
问题是,一旦后者被设置,以前与命令行一起工作的是不是,我有错误:
java.lang.IllegalArgumentException:无法解析字符串值“$ {input.file}”中的占位符'input.file'
现在,我知道使用两者远非理想(理想情况下,我甚至不应该使用
PropertyPlaceholderConfigurer
,而是使用PropertySourcesPlaceholderConfigurer
)。 然而,我对配置器没有选择余地。因此,我认为我必须用我的
PropertySource
改变一些东西,但我对如何以优雅的方式做到这一点感到不知所措。 我应该扩展PropertyPlaceholderConfigurer
以添加PropertySource
吗? 这甚至有可能吗?在这种情况下,最佳解决方案是什么? 即使模糊的线索也是受欢迎的,因为我不知道要走哪条路。
(Spring版本:4.1.6)
1.此
PropertyPlaceholderConfigurer
加载一些属性文件并应用一些额外的处理(例如,允许在属性文件中加密值)。I am having a bit of a difficulty here. I am designing a utility for which I require the ability for my Spring context to treat command-line arguments as properties. This was easily done:
if (args != null && args.length > 0) { PropertySource<?> ps = new SimpleCommandLinePropertySource(args); ctx.getEnvironment().getPropertySources().addFirst(ps); }
What I have a problem with is the next step: to be compliant with my enterprise framework, I must set a
PropertyPlaceholderConfigurer
they provide1. Easily done too.@Bean public PropertyPlaceholderConfigurer propertyPlaceholderConfigurer() { return new MyPropertyPlaceholderConfigurer(); }
The thing is, once the latter is set, what was previously working with the command-line is not, and I have errors:
java.lang.IllegalArgumentException: Could not resolve placeholder 'input.file' in string value "${input.file}"
Now, I am aware using both is far from ideal (and that ideally, I should not even be using
PropertyPlaceholderConfigurer
but ratherPropertySourcesPlaceholderConfigurer
). Yet, I have no choice as to the configurer.As a consequence, I think I must change something with my
PropertySource
, but I am at a loss as to how I can do it in an elegant way. Should I extend thePropertyPlaceholderConfigurer
to add thePropertySource
? Is that even possible?What is the best solution to go for in this case? Even vague leads are welcome, since I don't know in which way to go.
(Spring version: 4.1.6)
1. This
PropertyPlaceholderConfigurer
loads some properties files and apply some additional processing (e.g. to allow encrypted values in the properties files).
原文:https://stackoverflow.com/questions/33547837
最满意答案
相关问答
更多-
您没有提供足够的信息来提供完整的答案(*),但听起来您将要进行某种最小二乘曲线拟合。 fminsearch将fminsearch工作,但有更好的选择。 我倾向于使用统计工具箱中的lsqcurvefit ,但是优化工具箱中也有lsqcurvefit ,并且fit曲线拟合工具箱。 (*)您的数据究竟是什么? 在已知频率的正弦驱动力下,它是位移作为时间的函数吗? 但是您必须拥有多个驱动频率的数据,因为您需要了解多个频率的响应才能提取传输函数的所有5个参数,对吧? You haven't provided enou ...
-
EDU>> minreal(tsum) ans = 3 - s Continuous-time transfer function. 看到 http://www.mathworks.com/help/control/ref/minreal.html EDU>> minreal(tsum) ans = 3 - s Continuous-time transfer function. see http://www.mathworks.com/help/control/re ...
-
将传感器的频域数据转换为时域传递函数(Convert frequency Domain data of transducer to time Domain Transfer Function)[2023-08-06]
为了将频域响应转换为时域,需要执行傅立叶逆变换 。 在matlab中,这是通过函数ifft完成的。 让我们考虑你将第一个文件中的数据加载到变量magnitude ,并将第二个文件中的数据加载到变量phase 。 您必须首先将这两个变量合并为一个复数值矩阵 f_response = complex(magnitude.*cosd(phase),magnitude.*sind(phase)); f_response是传感器的实际响应,可以提供给ifft以获得时域响应。 但有一个并发症,即由ifft暗示的假定频 ... -
使用Mathematica Manipulate函数绘制传递函数(Using Mathematica Manipulate function to plot a transfer function)[2022-07-09]
编辑..拿2 .. Manipulate[ fplot = LogLogPlot[Abs[tfplotf /. s -> 2*Pi*I*f], {f, fmin1, fmax1}, PlotPoints -> 1000, PlotRange -> {{fmin1, fmax1}, {ymin1, ymax1}}, PlotLabel -> "tf Plot"], {{tfplotf, (3.333321894500285`*^ ... -
时域传递函数(transfer function in time domain)[2022-07-10]
这是一个非常常见的错误。 许多人似乎相信'意味着移调 ,但实际上它意味着共轭转置。 要简单地转置你应该使用.' 所以:改变 t = ifft([txy' tyx']); 成 t = ifft([txy.' tyx.']); This a very common mistake. Many people seem to believe ' means transpose, but actually it means conjugate transpose. To simply transpose you ... -
我相信这就是你要找的东西: 转移Fcn Block 关于Simulink的互联网文档,此块参考列表是一个很好的链接,可以随时使用。 I believe this is what you're looking for: Transfer Fcn Block With regard to internet documentation for Simulink, this Block Reference list is a good link to keep on hand.
-
如果你想只有正的非零指数,你可以乘以z^3 。 Matlab做了同样的事情。 (虽然我认为你不得不乘以z^-3来使所有指数为负...) Z = tf('z', 1/200) Z = z Sample time: 0.005 seconds Discrete-time transfer function. >> H = (1/8*(1/200))/(-Z^-2 - 2*Z^-1 + 2*Z^1 + Z^2) H = 0.000625 z^3 ----------------- ...
-
问题在于绘图而不是结果。 如果你没有指定'x轴'的值,matlab将创建一个虚拟变量,它从1开始并以向量的长度结束,基本上是1:length(y) 。 您应该创建自己的x向量(并根据@Florian的建议进行缩放): response = impulse(hz*Ts); timevector = (0:length(response)-1)*Ts; stem(timevector,reponse); grid minor; The problem is with the plotting rather t ...
-
替代传递函数(Substitute s in transfer function)[2021-12-04]
保存m文件有什么问题 function g = transferFun( s ) g = 1 ./ ( s + 3 ) 然后调用该函数 >> transferFun( -2.118 + 2.221*j ) What's wrong with saving m-file with function g = transferFun( s ) g = 1 ./ ( s + 3 ) And then calling the function >> transferFun( -2.118 + 2.2 ... -
我不相信Octave会这样做,但你当然可以自己创建logsig输出。 logsig传递函数(或Log-Sigmoid函数......或简称Sigmoid函数)简单地定义为: a = 1 ./ (1 + exp(-n)); n将是存储在向量/矩阵/等中的输入值。因此,只需将值放入矩阵/向量中,然后使用上面的代码将logsig函数应用于n定义的每个值。 例 n = [0; 1; -0.5; 0.5]; a = 1 ./ (1 + exp(-n)) a = 0.5000 0.7311 ...