8000 配置文件不支持空格,如:db.properties · Issue #1361 · nutzam/nutz · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

配置文件不支持空格,如:db.properties #1361

Open
luowenkun opened this issue Nov 30, 2017 · 9 comments
Open

配置文件不支持空格,如:db.properties #1361

luowenkun opened this issue Nov 30, 2017 · 9 comments
Milestone

Comments

@luowenkun
Copy link

配置文件不支持空格,如:db.properties
经测试发现db.properties的选项不支持空格。
比如数据库连接
db.username=root
db.password=666666
我用
db.username= root
db.password=666666配置后无法连接到数据库
或是在db.username=root root后面多了一个空格无法连接到数据库
db.password=密码 密码的前面或是后面出现空格都无法连接到数据库

由于在=后面很容易误操作出现空格,但是现在的编辑器很难发现后面有空格,这样导致在配置的时候出现问题,因此建议对相关的配置文件在值的前面或是后面把空格去掉

@luowenkun
Copy link
Author

db.maxActive=100 在100后面打空格也是出现报错的问题

[INFO ] 2017-11-30 18:09:39,529 org.nutz.lang.inject.InjectBySetter.inject(InjectBySetter.java:61) - Fail to value by setter
org.nutz.castor.FailToCastObjectException: Fail to cast '100 ' to
at org.nutz.castor.castor.String2Number.cast(String2Number.java:45)
at org.nutz.castor.castor.String2Number.cast(String2Number.java:19)
at org.nutz.castor.Castors.cast(Castors.java:252)
at org.nutz.castor.Castors.castTo(Castors.java:316)
at org.nutz.lang.inject.InjectBySetter.inject(InjectBySetter.java:46)
at org.nutz.ioc.impl.PropertiesProxy.make(PropertiesProxy.java:376)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.nutz.lang.Invoking$DefaultInvoker.invoke(Invoking.java:47)
at org.nutz.lang.Invoking.invoke(Invoking.java:192)
at org.nutz.lang.Mirror.invoke(Mirror.java:1120)
at org.nutz.ioc.impl.ObjectMakerImpl$1.born(ObjectMakerImpl.java:78)
at org.nutz.ioc.weaver.DefaultWeaver.born(DefaultWeaver.java:67)
at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:115)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:216)
at org.nutz.ioc.val.ReferValue.get(ReferValue.java:24)
at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:62)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:216)
at org.nutz.ioc.val.ReferValue.get(ReferValue.java:24)
at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:62)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:216)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:245)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:152)
at cn.wizzer.app.web.commons.filter.TokenFilter.(TokenFilter.java:22)
at cn.wizzer.app.web.commons.filter.TokenFilter$FC$62febe830a4a6764c634d9e263964cee.invoke(TokenFilter.java)
at org.nutz.lang.born.AbstractConstructorBorning.call(AbstractConstructorBorning.java:25)
at org.nutz.lang.born.EmptyArgsConstructorBorning.born(EmptyArgsConstructorBorning.java:14)
at org.nutz.lang.born.BornContext.doBorn(BornContext.java:60)
at org.nutz.lang.Mirror.born(Mirror.java:1010)
at org.nutz.mvc.impl.Loadings.evalObj(Loadings.java:335)
at org.nutz.mvc.impl.processor.AbstractProcessor.evalObj(AbstractProcessor.java:48)
at org.nutz.mvc.impl.processor.ActionFiltersProcessor.init(ActionFiltersProcessor.java:32)
at org.nutz.mvc.impl.NutActionChainMaker.eval(NutActionChainMaker.java:38)
at org.nutz.mvc.impl.UrlMappingImpl.add(UrlMappingImpl.java:54)
at org.nutz.mvc.impl.NutLoading.evalUrlMapping(NutLoading.java:205)
at org.nutz.mvc.impl.NutLoading.load(NutLoading.java:108)
at org.nutz.mvc.ActionHandler.(ActionHandler.java:19)
at org.nutz.mvc.NutFilter._init(NutFilter.java:91)
at org.nutz.mvc.NutFilter.init(NutFilter.java:69)
at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:279)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:260)
at org.apache.catalina.core.ApplicationFilterConfig.(ApplicationFilterConfig.java:105)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4700)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5340)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1408)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1398)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NumberFormatException: For input string: "100 "
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:580)

@wendal wendal added this to the 1.r.65 milestone Nov 30, 2017
@ywjno
Copy link
Member
ywjno commented Dec 1, 2017

properties文件的等号左右本来就不能有空格的吧

@wendal
Copy link
Member
wendal commented Dec 1, 2017

@ywjno 能的

@ywjno
Copy link
Member
ywjno commented Dec 1, 2017

看来你还要trim一下

@wendal
Copy link
Member
wendal commented Dec 1, 2017

jdk自带的properties处理,是去掉等号两侧的空格和key前面的空格

[空格]ABC[空格]=[空格]123[空格] 

得到的是 ABC=123[空格]

@wendal
Copy link
Member
wendal commented Dec 1, 2017

会不会有人会用到 空格结尾的value呢???

wendal added a commit that referenced this issue Dec 1, 2017
@wendal
Copy link
Member
wendal commented Dec 1, 2017

提交了个pull request, 考虑合并呢, 还是不合并呢...

@luowenkun
Copy link
Author

下个版本吧,反正暂时影响不是很大

@lihongjie0209
Copy link
Contributor

这个我也遇到过, 最后手动trim了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants
0