首页 \ 问答 \ 使用PropertyPlaceholderConfigurer和PropertySource(Using both PropertyPlaceholderConfigurer and PropertySource)

使用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 rather PropertySourcesPlaceholderConfigurer). 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 the PropertyPlaceholderConfigurer to add the PropertySource? 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
更新时间:2023-06-25 15:06

最满意答案

这是一个非常常见的错误。 许多人似乎相信'意味着移调 ,但实际上它意味着共轭转置。 要简单地转置你应该使用.'

所以:改变

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 should use .'

So: change

t = ifft([txy' tyx']);

into

t = ifft([txy.' tyx.']);

相关问答

更多
  • 您没有提供足够的信息来提供完整的答案(*),但听起来您将要进行某种最小二乘曲线拟合。 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 ...
  • 为了将频域响应转换为时域,需要执行傅立叶逆变换 。 在matlab中,这是通过函数ifft完成的。 让我们考虑你将第一个文件中的数据加载到变量magnitude ,并将第二个文件中的数据加载到变量phase 。 您必须首先将这两个变量合并为一个复数值矩阵 f_response = complex(magnitude.*cosd(phase),magnitude.*sind(phase)); f_response是传感器的实际响应,可以提供给ifft以获得时域响应。 但有一个并发症,即由ifft暗示的假定频 ...
  • 编辑..拿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`*^ ...
  • 这是一个非常常见的错误。 许多人似乎相信'意味着移调 ,但实际上它意味着共轭转置。 要简单地转置你应该使用.' 所以:改变 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 ...
  • 保存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 ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)