我有一个spring应用程序,我希望用户能够更改首选的语言环境.目前,用户可以更改当前会话的区域设置,但我希望能够保存用户选项,这样无论何时登录,都会使用已保存的区域设置(如果存在).我有一个mysql数据库,我用它来存储用户区域设置首选项.我创建了一个自定义AuthenticationSuccessHandler来处理将语言环境更改为已保存的语言环境,该语言环境适用于已将语言环境保存到数据库的用户.但是,我不知道该怎么做的是在更改选项时保存语言环境.代码如下:
/**
* Creates and gets the LocaleResolver
* @return LocaleResolver
*/
@Bean
public LocaleResolver localeResolver() {
SessionLocaleResolver slr = new SessionLocaleResolver();
slr.setDefaultLocale(Locale.getDefault());
logger.debug("Setting locale to: " + Locale.getDefault());
return slr;
}
/**
* Creates and gets the LocaleChangeInterceptor
* @return LocaleChangeInterceptor
*/
@Bean
public LocaleChangeInterceptor localeChangeInterceptor() {
LocaleChangeInterceptor lci = new LocaleChangeInterceptor();
lci.setParamName("lang");
logger.debug("localeChangeInterceptor called " + Locale.getDefault());
return lci;
}
Run Code Online (Sandbox Code Playgroud)
SecurityConfig类:
@Configuration("SecurityConfig")
@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled=true)
class SecurityConfig extends WebSecurityConfigurerAdapter
{
@Autowired
@Qualifier("CustomAuthenticationSuccessHandler")
private CustomAuthenticationSuccessHandler authenticationSuccessHandler;
@Override
protected void configure(HttpSecurity …Run Code Online (Sandbox Code Playgroud) 我创建了一个使用 mybatis 连接到 mysql 数据库的新项目。这是我使用 mybatis 的第二个项目,所以我对它很熟悉,但是在调用 save 方法时出现以下错误:
2019-03-05 10:08:01.031 ERROR 86438 --- [nio-9905-exec-1] cqfrcResolveRestController :启动预设时出错:绑定语句无效(未找到):com.qlsdistribution.fps.resolverender.data.mybatis。 mapper.ResolveJobReportMapper.saveResolveJobReport org.apache.ibatis.binding.BindingException:无效的绑定语句(未找到):com.qlsdistribution.fps.resolverender.data.mybatis.mapper.ResolveJobReportMapper.saveResolveJobReport at org.apache.Mapperatis.saveResolveJobReport $SqlCommand.(MapperMethod.java:232) ~[mybatis-3.5.0.jar:3.5.0] at org.apache.ibatis.binding.MapperMethod.(MapperMethod.java:50) ~[mybatis-3.5.0. jar:3.5.0] 在 org.apache.ibatis.binding.MapperProxy.lambda$cachedMapperMethod$0(MapperProxy.java:62) ~[mybatis-3.5.0.jar:3.5.0] 在 java.util.concurrent.ConcurrentHashMap .computeIfAbsent(ConcurrentHashMap.java:1660) ~[na:1.8.0_101] 在 org.apache.ibatis.binding.MapperProxy.cachedMapperMethod(MapperProxy.java:62) ~[mybatis-3.5.0.jar:3.5.0] .....
我的 mybatis 配置文件如下(在 src/main/resources 中):
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<settings>
<!-- changes from the defaults -->
<setting name="lazyLoadingEnabled" value="true" />
<!-- Mybatis logging -->
<setting name="logImpl" value="LOG4J2"/>
</settings>
<typeAliases>
<package name="com.qlsdistribution.fps.resolverender.data.mybatis.domain"/>
</typeAliases>
<mappers>
<mapper resource="mapper/ResolveJobReport.xml"/> …Run Code Online (Sandbox Code Playgroud) 我已将一个项目从Java 1.8迁移到Java11。在此过程中,我必须安装较新版本的eclipse才能使用Java 11 jdk。
Eclipse IDE for Enterprise Java Developers.
Version: 2018-12 (4.10.0)
Build id: 20181214-0600
Run Code Online (Sandbox Code Playgroud)
该应用程序是一个maven项目,可以从命令行成功编译,但是eclipse抱怨它无法解析javax.xml.datatype.XMLGregorianCalendar。
我已经使用右键单击项目Maven->更新项目,从Eclipse更新了Maven项目。
我从项目中可以看到maven依赖项jaxp-api-1.4.2.jar被包括在内,并且类javax.xml.datatype.XMLGregorianCalendar存在。
如何解决Eclipse抱怨类javax.xml.datatype.XMLGregorianCalendar无法解决的问题?
带有未解析的javax.xml.datatype.XMLGregorianCalendar的类:
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2018.08.17 at 01:14:19 PM BST
//
package com.qlsdistribution.fps.production.contentagent;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlSchemaType;
import …Run Code Online (Sandbox Code Playgroud)