-
Notifications
You must be signed in to change notification settings - Fork 252
项目开发记录
Nicky edited this page Dec 2, 2018
·
10 revisions
【mybatis Exception】
Invalid bound statement (not found): ①Mapepr.xml文件中文nameapce没有和mapper接口发生映射 ②有可能是在IDEA编辑器运行的项目,需要project structure设置mybatis的xml文件夹为resource
获取后台timestamp类型数据,页面得到一串unix long类型数据,解决方案是用fastjson的@JSONField注解可以解决
@JSONField(format ="yyyy-MM-dd HH:mm:ss")
private Date createTime;
【SpringBoot扫描问题】 mybatis默认typeAliasesPackage是不支持正则扫描package的,项目扫描不到用通配符表示的包路径com.muses.taoshop.*.entity, 解决方案是typeAliasesPackage正则扫描package中的bean 解决方案来自csdn博客链接
public static String setTypeAliasesPackage(String typeAliasesPackage) {
ResourcePatternResolver resolver = (ResourcePatternResolver) new PathMatchingResourcePatternResolver();
MetadataReaderFactory metadataReaderFactory = new CachingMetadataReaderFactory(
resolver);
typeAliasesPackage = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX
+ ClassUtils.convertClassNameToResourcePath(typeAliasesPackage)
+ "/" + DEFAULT_RESOURCE_PATTERN;
try {
List<String> result = new ArrayList<String>();
Resource[] resources = resolver.getResources(typeAliasesPackage);
if (resources != null && resources.length > 0) {
MetadataReader metadataReader = null;
for (Resource resource : resources) {
if (resource.isReadable()) {
metadataReader = metadataReaderFactory
.getMetadataReader(resource);
try {
// System.out.println(Class.forName(metadataReader.getClassMetadata().getClassName()).getPackage().getName());
result.add(Class
.forName(
metadataReader.getClassMetadata()
.getClassName())
.getPackage().getName());
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
}
}
if (result.size() > 0) {
HashSet<String> h = new HashSet<String>(result);
result.clear();
result.addAll(h);
typeAliasesPackage=String.join(",",(String[]) result.toArray(new String[0]));
System.out.println(typeAliasesPackage);
} else {
throw new RuntimeException(
"mybatis typeAliasesPackage 路径扫描错误,参数typeAliasesPackage:"
+ typeAliasesPackage + "未找到任何包");
}
} catch (IOException e) {
e.printStackTrace();
}
return typeAliasesPackage;
}
【Themeleaf】 idea thymeleaf页面变量报错解决 链接
【Dubbo搭建】 Detected both log4j-over-slf4j.jar AND bound slf4j-log4j12.jar on the class path, preempting StackOverflowError
<dependency>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
<version>${zookeeper.version}</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</exclusion>
</exclusions>
</dependency>
参考资料: