解决org.springframework.context.NoSuchMessageException: No message found under code 'login.validate.er
转自:https://blog.csdn.net/steveguoshao/article/details/36184971
在项目中遇到
org.springframework.context.NoSuchMessageException: No message found under code 'login.validate.error' for locale 'zh_CN'.
搞了半天也没解决,谷歌了看别人也遇到这样的问题,看他是路径问题,当初看别人的时候怎么没有想到呢?结果自己也是路径问题,没有把消息加载进来,
刚开始的spring配置:
<!-- 国际化的消息资源文件(本系统中主要用于显示/错误消息定制) -->
<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="basenames">
<list>
<!-- 在web环境中一定要定位到classpath 否则默认到当前web应用下找 -->
<value>classpath:/messages</value>
<value>classpath:/ValidationMessages</value>
</list>
</property>
<property name="useCodeAsDefaultMessage" value="false"/>
<property name="defaultEncoding" value="UTF-8"/>
<property name="cacheSeconds" value="60"/>
</bean>
而我message的路径是resources/message/messages.propeties
当然加载不到了,后来改成:
<!-- 国际化的消息资源文件(本系统中主要用于显示/错误消息定制) -->
<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="basenames">
<list>
<!-- 在web环境中一定要定位到classpath 否则默认到当前web应用下找 -->
<value>classpath:/messages/messages</value>
<value>classpath:/messages/ValidationMessages</value>
</list>
</property>
<property name="useCodeAsDefaultMessage" value="false"/>
<property name="defaultEncoding" value="UTF-8"/>
<property name="cacheSeconds" value="60"/>
</bean>
解决org.springframework.context.NoSuchMessageException: No message found under code 'login.validate.er的更多相关文章
- 关于国际化时报org.springframework.context.NoSuchMessageException错,具体到No message found under code '你的键名' for locale 'zh_CN'.的解决方案
使用IntelliJ IDEA开发工具解决方案: 总结原因,解决方案: 1,在使用messageSource.getMessage方法时,参数1的键名跟属性文件中键名不一致,比如Controller中 ...
- 关于Spring 国际化 No message found under code 的解决方案
用spring做国际化时经常会报: org.springframework.context.NoSuchMessageException: No message found under code 'u ...
- nested exception is org.springframework.context.ApplicationContextException: Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean.报错解决
近期在学springboot,学的时候遇到这个错,网上查了好多,改了不行,后来发现自己的配置类没有加@SpringBootApplication注解 Exception encountered dur ...
- Caused by: java.lang.ClassNotFoundException: org.springframework.context.ApplicationContextAware
1.错误描述 usage: java org.apache.catalina.startup.Catalina [ -config {pathname} ] [ -nonaming ] { -help ...
- Mingyang.net:org.springframework.context.annotation.ConflictingBeanDefinitionException
org.springframework.context.annotation.ConflictingBeanDefinitionException: Annotation-specified bean ...
- java.lang.NoClassDefFoundError: org/springframework/context/ApplicationContext
***************************错误提示************************************************ SEVERE: A child cont ...
- Unable to start web server; nested exception is org.springframework.context.ApplicationContextException: Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean.
SpringBoot启动时的异常信息如下: "C:\Program Files\Java\jdk1.8.0_161\bin\java" ......... com.fangxing ...
- spring Boot 出现:org.springframework.context.ApplicationContextException: Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean.
org.springframework.context.ApplicationContextException: Unable to start ServletWebServerApplication ...
- Context namespace element 'component-scan' and its parser class [org.springframework.context.annotation.ComponentScanBeanDefinitionParser] are only available on JDK 1.5 and higher
异常信息如下: 错误: Unexpected exception parsing XML document from class path resource [spring/applicationCo ...
随机推荐
- struts2访问ServletAPI方式和获取参数的方式
一.访问ServletAPI的三种方式 方式1:通过让Action类去实现感知接口. 此时项目依赖:servlet-api.jar. ServletRequestAware:感知HttpServlet ...
- sublime 自动添加兼容前缀插件autoprefixer
安装插件autoprefixer步骤: 1.确保Node.js已经安装,未安装请 点击 这里>> 2.下载autoprefixer插件 https://github.com/sindres ...
- hangfire docker-compose 运行
hangfire 是一款基于.net 的任务调度系统 docker-compose 文件 version: '3' services: hangfire: image: direktchark/han ...
- hasura graphql-engine v1.0.0-alpha26 版本新功能
hasura 发布了graphql-engine v1.0.0-alpha26 版本,有一些破坏的变动,以及方便的新特性 破坏性变动 order_by 从 order_by: id_asc 为 ord ...
- Zxing图片拉伸解决 Android 二维码扫描
版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/aaawqqq/article/details/24852915 二维码扫描 Android Zx ...
- 用C#通过反射实现动态调用WebService 告别Web引用(转载)
我们都知道,调用WebService可以在工程中对WebService地址进行WEB引用,但是这确实很不方便.我想能够利用配置文件灵活调用WebService.如何实现呢? 用C#通过反射实现动态调用 ...
- setsockopt IP_ADD_MEMBERSHIP error!No such device的解决方案
/mnt # ./onvifserver Happytime onvif server version 2.6Onvif server running at 192.168.1.10:8000crea ...
- 4.图像sensor的特性和驱动解析
修改 摄像头SDK中支持的sensor需要做的事 例如:ar0130 --> ov9712 1.修改加载load3518e脚本的参数 vi /etc/profile ./load3518e -i ...
- CentOS 7安装和配置ssh
1. 安装openssh-server yum install -y openssl openssh-server 2. 修改配置文件 用vim打开配置文件/etc/ssh/sshd_config ...
- BASIC-6_蓝桥杯_杨辉三角形
示例代码: #include <stdio.h>#include <stdlib.h> int main(void){ int n = 0 ; int i = 0 , j = ...