Bean类无法扫描到或者指定注解的类无法启动后扫描到
响应注解所在的类或者相应的Bean没有在启动Application所在的相同包目录下
properties 文件读取中文乱码问题
val props = Properties()
var inputStream: InputStream? = null
try {
inputStream = this::class.java.classLoader.getResourceAsStream(propertiesName)
if (inputStream != null) {
val isr = InputStreamReader(inputStream, "UTF-8")
val br = BufferedReader(isr)
props.load(br)
props.load(isr)
} else {
getLogUtil().logE(this::class.java, "${propertiesName}配置文件加载异常")
}
} catch (e: Exception) {
getLogUtil().logE(this::class.java, "${propertiesName}配置文件加载异常")
} finally {
try {
inputStream?.close()
} catch (e: IOException) {
getLogUtil().logE(this::class.java, "${propertiesName}文件流关闭出现异常")
}
}
Controller返回字符串中文乱码问题
@Configuration
class MyConfiguration : WebMvcConfigurationSupport() {
override fun extendMessageConverters(converters: List<HttpMessageConverter<*>?>) {
for (converter in converters) {
if (converter is StringHttpMessageConverter) {
converter.defaultCharset = StandardCharsets.UTF_8
}
}
}
}
继承了WebMvcConfigurationSupport,则在yml中配置的相关内容会失效,或者静态接口无法访问失效
@Configuration
class MyConfiguration : WebMvcConfigurationSupport() {
override fun addResourceHandlers(registry: ResourceHandlerRegistry) {
registry.addResourceHandler("
override fun configureDefaultServletHandling(configurer: DefaultServletHandlerConfigurer) {
configurer.enable()
}
}
|