Spring Roo 2.0.0.RC1:如果我在临床示例中使用我的新语言插件,我会得到很长的堆栈跟踪

Spring Roo 2.0.0.RC1: If i use my new language Addon in clinic example i get long stacktrace

测试新语言插件

我现在有德语语言插件,并在临床示例中使用它。

安装新语言插件后我设置

web mvc language --code de --useAsDefault in clinic.roo 

之前

web mvc language --code es

当我启动应用程序时,所有内容都是德语。但是在我启动应用程序的命令 shell 中,出现了很长的堆栈跟踪。

2017-03-08 12:00:53.176 ERROR - QP: - 9544 --- [nio-8082-exec-2] org.thymeleaf.TemplateEngine             : [THYMELEAF][http-nio-8082-exec-2] Exception processing template "index": An error happened during template parsing (template: "class path resource [templates/index.html]")

org.thymeleaf.exceptions.TemplateInputException: An error happened during template parsing (template: "class path resource [templates/index.html]")
        at org.thymeleaf.templateparser.markup.AbstractMarkupTemplateParser.parse(AbstractMarkupTemplateParser.java:241) ~[thymeleaf-3.0.0.RELEASE.jar:3.0.0.RELEASE]
        at org.thymeleaf.templateparser.markup.AbstractMarkupTemplateParser.parseStandalone(AbstractMarkupTemplateParser.java:100) ~[thymeleaf-3.0.0.RELEASE.jar:3.0.0.RELEASE]
        at org.thymeleaf.engine.TemplateManager.parseAndProcess(TemplateManager.java:667) ~[thymeleaf-3.0.0.RELEASE.jar:3.0.0.RELEASE]
        at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1087) [thymeleaf-3.0.0.RELEASE.jar:3.0.0.RELEASE]
        at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1061) [thymeleaf-3.0.0.RELEASE.jar:3.0.0.RELEASE]
        at org.thymeleaf.spring4.view.ThymeleafView.renderFragment(ThymeleafView.java:335) [thymeleaf-spring4-3.0.0.RELEASE.jar:3.0.0.RELEASE]
        at org.thymeleaf.spring4.view.ThymeleafView.render(ThymeleafView.java:189) [thymeleaf-spring4-3.0.0.RELEASE.jar:3.0.0.RELEASE]
        at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1257) [spring-webmvc-4.3.3.RELEASE.jar:4.3.3.RELEASE]
...

只有来自堆栈跟踪的一小段。 然后我切换到西班牙语或英语没有堆栈跟踪。 当我切换回德语时,堆栈跟踪发生。 为什么?怎么了?

我在 northwind-multimodule 中测试新语言并获得堆栈跟踪 当我切换到德语并且菜单不起作用后。我可以添加 url param lang=en 然后菜单再次工作。

另注:

用于切换德语语言的标签所有标签都可以(我已将它们放在 message_de.properties 中)但在西班牙语或英语中,德语标签不可以。

在德语的消息属性中没有 language_Label 属性,因为在 I18N 插件中,德语的消息属性没有 language_Label。 该插件现在与其他语言无关。 我已经手动添加了这个条目,然后一切正常。

好吧,我测试它新只使用正常 message.properties 并将名称更改为 message_de.properties。 然后构建新插件并在临床示例中使用语言并获取堆栈跟踪:

2017-03-16 12:48:26.179  WARN - QP: - 6104 --- [nio-8082-exec-4] o.s.w.s.r.WebJarsResourceResolver
      : WebJar version conflict for "momentjs/locale/de.js"

org.webjars.MultipleMatchesException: Multiple matches found for locale/de.js. Please provide a more
 specific path, for example by including a version number.
        at org.webjars.WebJarAssetLocator.getFullPath(WebJarAssetLocator.java:259) ~[webjars-locator
-core-0.30.jar:na]
        at org.webjars.WebJarAssetLocator.getFullPath(WebJarAssetLocator.java:200) ~[webjars-locator
-core-0.30.jar:na]
        at org.springframework.web.servlet.resource.WebJarsResourceResolver.findWebJarResourcePath(W
ebJarsResourceResolver.java:108) [spring-webmvc-4.3.3.RELEASE.jar:4.3.3.RELEASE]
        at org.springframework.web.servlet.resource.WebJarsResourceResolver.resolveResourceInternal(
WebJarsResourceResolver.java:79) [spring-webmvc-4.3.3.RELEASE.jar:4.3.3.RELEASE]
        at org.springframework.web.servlet.resource.AbstractResourceResolver.resolveResource(Abstrac
tResourceResolver.java:46) [spring-webmvc-4.3.3.RELEASE.jar:4.3.3.RELEASE]
        at org.springframework.web.servlet.resource.DefaultResourceResolverChain.resolveResource(Def
aultResourceResolverChain.java:57) [spring-webmvc-4.3.3.RELEASE.jar:4.3.3.RELEASE]
        at org.springframework.web.servlet.resource.CachingResourceResolver.resolveResourceInternal(
CachingResourceResolver.java:78) [spring-webmvc-4.3.3.RELEASE.jar:4.3.3.RELEASE]
        at org.springframework.web.servlet.resource.AbstractResourceResolver.resolveResource(Abstrac
tResourceResolver.java:46) [spring-webmvc-4.3.3.RELEASE.jar:4.3.3.RELEASE]
        at org.springframework.web.servlet.resource.DefaultResourceResolverChain.resolveResource(Def
aultResourceResolverChain.java:57) [spring-webmvc-4.3.3.RELEASE.jar:4.3.3.RELEASE]
        at org.springframework.web.servlet.resource.ResourceHttpRequestHandler.getResource(ResourceH
ttpRequestHandler.java:432) [spring-webmvc-4.3.3.RELEASE.jar:4.3.3.RELEASE]
        at org.springframework.web.servlet.resource.ResourceHttpRequestHandler.handleRequest(Resourc
eHttpRequestHandler.java:333) [spring-webmvc-4.3.3.RELEASE.jar:4.3.3.RELEASE]
        at org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter.handle(HttpRequestHandlerAd
apter.java:51) [spring-webmvc-4.3.3.RELEASE.jar:4.3.3.RELEASE]
        at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:963)
[spring-webmvc-4.3.3.RELEASE.jar:4.3.3.RELEASE]
        at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897) [
spring-webmvc-4.3.3.RELEASE.jar:4.3.3.RELEASE]
        at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970
) [spring-webmvc-4.3.3.RELEASE.jar:4.3.3.RELEASE]
        at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861) [spring
-webmvc-4.3.3.RELEASE.jar:4.3.3.RELEASE]
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:622) [tomcat-embed-core-8.5.5.jar
:8.5.5]
        at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846) [spri
ng-webmvc-4.3.3.RELEASE.jar:4.3.3.RELEASE]
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) [tomcat-embed-core-8.5.5.jar
:8.5.5]
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.j
ava:230) [tomcat-embed-core-8.5.5.jar:8.5.5]
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
 [tomcat-embed-core-8.5.5.jar:8.5.5]
        at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) [tomcat-embed-webs
ocket-8.5.5.jar:8.5.5]
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.j
ava:192) [tomcat-embed-core-8.5.5.jar:8.5.5]
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
 [tomcat-embed-core-8.5.5.jar:8.5.5]
        at org.springframework.web.servlet.resource.ResourceUrlEncodingFilter.doFilterInternal(Resou
rceUrlEncodingFilter.java:53) [spring-webmvc-4.3.3.RELEASE.jar:4.3.3.RELEASE]
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:10
7) [spring-web-4.3.3.RELEASE.jar:4.3.3.RELEASE]
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.j
ava:192) [tomcat-embed-core-8.5.5.jar:8.5.5]
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
 [tomcat-embed-core-8.5.5.jar:8.5.5]
        at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:
208) [spring-security-web-4.1.3.RELEASE.jar:4.1.3.RELEASE]
        at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:177) [sp
ring-security-web-4.1.3.RELEASE.jar:4.1.3.RELEASE]
        at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy
.java:346) [spring-web-4.3.3.RELEASE.jar:4.3.3.RELEASE]
        at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:
262) [spring-web-4.3.3.RELEASE.jar:4.3.3.RELEASE]
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.j
ava:192) [tomcat-embed-core-8.5.5.jar:8.5.5]
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
 [tomcat-embed-core-8.5.5.jar:8.5.5]
        at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter
.java:99) [spring-web-4.3.3.RELEASE.jar:4.3.3.RELEASE]
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:10
7) [spring-web-4.3.3.RELEASE.jar:4.3.3.RELEASE]
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.j
ava:192) [tomcat-embed-core-8.5.5.jar:8.5.5]
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
 [tomcat-embed-core-8.5.5.jar:8.5.5]
        at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormConte
ntFilter.java:89) [spring-web-4.3.3.RELEASE.jar:4.3.3.RELEASE]
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:10
7) [spring-web-4.3.3.RELEASE.jar:4.3.3.RELEASE]
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.j
ava:192) [tomcat-embed-core-8.5.5.jar:8.5.5]
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
 [tomcat-embed-core-8.5.5.jar:8.5.5]
        at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFi
lter.java:77) [spring-web-4.3.3.RELEASE.jar:4.3.3.RELEASE]
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:10
7) [spring-web-4.3.3.RELEASE.jar:4.3.3.RELEASE]
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.j
ava:192) [tomcat-embed-core-8.5.5.jar:8.5.5]
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
 [tomcat-embed-core-8.5.5.jar:8.5.5]
        at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncoding
Filter.java:197) [spring-web-4.3.3.RELEASE.jar:4.3.3.RELEASE]
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:10
7) [spring-web-4.3.3.RELEASE.jar:4.3.3.RELEASE]
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.j
ava:192) [tomcat-embed-core-8.5.5.jar:8.5.5]
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
 [tomcat-embed-core-8.5.5.jar:8.5.5]
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198) [tomc
at-embed-core-8.5.5.jar:8.5.5]
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:108) [tomc
at-embed-core-8.5.5.jar:8.5.5]
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472) [t
omcat-embed-core-8.5.5.jar:8.5.5]
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140) [tomcat-emb
ed-core-8.5.5.jar:8.5.5]
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) [tomcat-embe
d-core-8.5.5.jar:8.5.5]
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) [tomcat-
embed-core-8.5.5.jar:8.5.5]
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349) [tomcat-embed
-core-8.5.5.jar:8.5.5]
        at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:784) [tomcat-embed-
core-8.5.5.jar:8.5.5]
        at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) [tomcat-
embed-core-8.5.5.jar:8.5.5]
        at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:802) [
tomcat-embed-core-8.5.5.jar:8.5.5]
        at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1410) [tomc
at-embed-core-8.5.5.jar:8.5.5]
        at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-e
mbed-core-8.5.5.jar:8.5.5]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0
_121]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0
_121]
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomca
t-embed-core-8.5.5.jar:8.5.5]
        at java.lang.Thread.run(Thread.java:745) [na:1.8.0_121]

您似乎发现了当语言不是英语或西班牙语时 Roo 生成的 Thymeleaf 布局以及 moment.js 库的 webjar 的问题。

要解决它,您必须在文件夹 src/main/resources/templates/layouts 中编辑项目中生成的布局,然后找到以下行:

<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.13.0/locale/es.js" data-th-src="@{/webjars/momentjs//locale/}+ ${#locale.language}+'.js'" data-th-if="${#locale.language} != 'en' and ${#locale.language} != 'es'">
  </script>

似乎 moment.js webjar 包含所有区域设置相关文件的两个副本,webjars 解析器找到了它们但不知道使用哪一个。要解决它,必须使用带有 webjar 版本的路径。 URL 的格式也不正确。用这个替换之前的片段:

<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.13.0/locale/es.js" data-th-src="@{/webjars/momentjs/2.13.0/locale}+ '/' + ${#locale.language}+'.js'" data-th-if="${#locale.language} != 'en' and ${#locale.language} != 'es'">
  </script>