idea 本地运行打包都正常,但发布平台运行不起来
多数据源
@MapperScan(basePackages = {"com.kestrel.saas.mapper"},
sqlSessionFactoryRef = "sqlSessionFactory")
@MapperScan(basePackages = "com.kestrel.saas.mapper.collect", sqlSessionFactoryRef = "collectSqlSessionFactory")
yml
spring:
application:
name: iroq-pro
profiles:
active: dev
mybatis-plus:
mapper-locations: classpath*:mappers/*.xml,classpath*:collect-mappers/*.xml
pom.xml 依赖
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.1.1</version>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>0.9.1</version>
</dependency>
<dependency>
<groupId>com.auth0</groupId>
<artifactId>java-jwt</artifactId>
<version>3.4.0</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
<version>2.2.8</version>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-core</artifactId>
<version>3.3.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-extension</artifactId>
<version>3.3.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.3.2</version>
<scope>compile</scope>
</dependency>
</dependencies>
发布平台错误 log
08:00 at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:439)
08:00 at org.springframework.boot.SpringApplication.run(SpringApplication.java:339)
08:00 at org.springframework.boot.SpringApplication.run(SpringApplication.java:1340)
08:00 at org.springframework.boot.SpringApplication.run(SpringApplication.java:1329)
08:00 at com.kestrel.App.main(App.java:37)
08:00 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
08:00 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
08:00 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
08:00 at java.lang.reflect.Method.invoke(Method.java:498)
08:00 at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49)
08:00 at org.springframework.boot.loader.Launcher.launch(Launcher.java:108)
08:00 at org.springframework.boot.loader.Launcher.launch(Launcher.java:58)
08:00 at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:88)
08:00 Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.ibatis.session.SqlSessionFactory]: Factory method 'SqlSessionFactory' threw exception; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: 'URL [jar:file:/opt/app.jar!/BOOT-INF/classes!/collect-mappers/QuerydetailMapper.xml]'; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. The XML location is 'URL [jar:file:/opt/app.jar!/BOOT-INF/classes!/collect-mappers/QuerydetailMapper.xml]'. Cause: java.lang.IllegalArgumentException: Result Maps collection already contains value for com.kestrel.saas.mapper.collect.QuerydetailMapper.QuerydetailMap
08:00 at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185)
08:00 at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:653)
08:00 ... 28 common frames omitted
08:00 Caused by: org.springframework.core.NestedIOException: Failed to parse mapping resource: 'URL [jar:file:/opt/app.jar!/BOOT-INF/classes!/collect-mappers/QuerydetailMapper.xml]'; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. The XML location is 'URL [jar:file:/opt/app.jar!/BOOT-INF/classes!/collect-mappers/QuerydetailMapper.xml]'. Cause: java.lang.IllegalArgumentException: Result Maps collection already contains value for com.kestrel.saas.mapper.collect.QuerydetailMapper.QuerydetailMap
08:00 at com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean.buildSqlSessionFactory(MybatisSqlSessionFactoryBean.java:593)
08:00 at com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean.afterPropertiesSet(MybatisSqlSessionFactoryBean.java:429)
08:00 at com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean.getObject(MybatisSqlSessionFactoryBean.java:626)
08:00 at com.kestrel.saas.config.CollectDataSourceConfig.SqlSessionFactory(CollectDataSourceConfig.java:47)
08:00 at com.kestrel.saas.config.CollectDataSourceConfig$$EnhancerBySpringCGLIB$$691472a0.CGLIB$SqlSessionFactory$1(<generated>)
08:00 at com.kestrel.saas.config.CollectDataSourceConfig$$EnhancerBySpringCGLIB$$691472a0$$FastClassBySpringCGLIB$$15a8d1fe.invoke(<generated>)
08:00 at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244)
08:00 at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:331)
08:00 at com.kestrel.saas.config.CollectDataSourceConfig$$EnhancerBySpringCGLIB$$691472a0.SqlSessionFactory(<generated>)
08:00 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
08:00 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
08:00 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
08:00 at java.lang.reflect.Method.invoke(Method.java:498)
08:00 at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154)
08:00 ... 29 common frames omitted
08:00 Caused by: org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. The XML location is 'URL [jar:file:/opt/app.jar!/BOOT-INF/classes!/collect-mappers/QuerydetailMapper.xml]'. Cause: java.lang.IllegalArgumentException: Result Maps collection already contains value for com.kestrel.saas.mapper.collect.QuerydetailMapper.QuerydetailMap
08:00 at org.apache.ibatis.builder.xml.XMLMapperBuilder.configurationElement(XMLMapperBuilder.java:122)
08:00 at org.apache.ibatis.builder.xml.XMLMapperBuilder.parse(XMLMapperBuilder.java:94)
08:00 at com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean.buildSqlSessionFactory(MybatisSqlSessionFactoryBean.java:591)
08:00 ... 42 common frames omitted
08:00 Caused by: java.lang.IllegalArgumentException: Result Maps collection already contains value for com.kestrel.saas.mapper.collect.QuerydetailMapper.QuerydetailMap
08:00 at org.apache.ibatis.session.Configuration$StrictMap.put(Configuration.java:947)
08:00 at org.apache.ibatis.session.Configuration$StrictMap.put(Configuration.java:903)
08:00 at org.apache.ibatis.session.Configuration.addResultMap(Configuration.java:660)
08:00 at org.apache.ibatis.builder.MapperBuilderAssistant.addResultMap(MapperBuilderAssistant.java:209)
08:00 at org.apache.ibatis.builder.ResultMapResolver.resolve(ResultMapResolver.java:47)
08:00 at org.apache.ibatis.builder.xml.XMLMapperBuilder.resultMapElement(XMLMapperBuilder.java:288)
08:00 at org.apache.ibatis.builder.xml.XMLMapperBuilder.resultMapElement(XMLMapperBuilder.java:253)
08:00 at org.apache.ibatis.builder.xml.XMLMapperBuilder.resultMapElements(XMLMapperBuilder.java:245)
08:00 at org.apache.ibatis.builder.xml.XMLMapperBuilder.configurationElement(XMLMapperBuilder.java:118)
08:00 ... 44 common frames omitted
08:00
QuerydetailMapper.xml 文件
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.kestrel.saas.mapper.collect.QuerydetailMapper">
<sql id="Base_Column_List">
identify,
identify_time,
create_time,
id,
sourcesQuery,
queryIp,
queryTime,
productPc
</sql>
<resultMap type="com.kestrel.saas.entity.Querydetail" id="QuerydetailMap">
<result property="identify" column="identify" jdbcType="VARCHAR"/>
<result property="identifyTime" column="identify_time" jdbcType="VARCHAR"/>
<result property="createTime" column="create_time" jdbcType="VARCHAR"/>
<result property="id" column="id" jdbcType="VARCHAR"/>
<result property="sourcesquery" column="sourcesQuery" jdbcType="VARCHAR"/>
<result property="queryip" column="queryIp" jdbcType="VARCHAR"/>
<result property="querytime" column="queryTime" jdbcType="VARCHAR"/>
<result property="productpc" column="productPc" jdbcType="VARCHAR"/>
</resultMap>
<!-- 批量插入 -->
<insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
insert into IrQuerydetail(identify, identify_time, create_time, id, sourcesQuery, queryIp, queryTime, productPc)
values
<foreach collection="entities" item="entity" separator=",">
(#{entity.identify}, #{entity.identifyTime}, #{entity.createTime}, #{entity.sourcesquery}, #{entity.queryip}, #{entity.querytime}, #{entity.productpc})
</foreach>
</insert>
<!-- 批量插入或按主键更新 -->
<insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
insert into IrQuerydetail(identify, identify_time, create_time, sourcesQuery, queryIp, queryTime, productPc)
values
<foreach collection="entities" item="entity" separator=",">
(#{entity.identify}, #{entity.identifyTime}, #{entity.createTime}, #{entity.sourcesquery}, #{entity.queryip}, #{entity.querytime}, #{entity.productpc})
</foreach>
on duplicate key update
identify = if(values(identify) is not null,values(identify) ,identify), identify_time = if(values(identify_time) is not null,values(identify_time) ,identify_time), create_time = if(values(create_time) is not null,values(create_time) ,create_time), sourcesQuery = if(values(sourcesQuery) is not null,values(sourcesQuery) ,sourcesQuery), queryIp = if(values(queryIp) is not null,values(queryIp) ,queryIp), queryTime = if(values(queryTime) is not null,values(queryTime) ,queryTime), productPc = if(values(productPc) is not null,values(productPc) ,productPc) </insert>
<select id="countByQuerytime" resultType="java.lang.Integer">
select count(1)
from IrQuerydetail
<where>
<if test="querytime != null and querytime != ''">
and queryTime>=#{querytime,jdbcType=VARCHAR}
</if>
</where>
</select>
<select id="latestList" resultType="com.kestrel.saas.dto.IrQueryStatistics.QueryStatisticsMapDto">
select qsd.queryTime,qsd.productPc,qs.productName,qs.productSort from IrQuerydetail qsd left join IrQueryStatistics qs on qsd.productPc=qs.productPc order by queryTime desc limit #{pageSize};
</select>
<select id="groupByMonth" resultType="java.util.Map">
select DATE_FORMAT(FROM_UNIXTIME(queryTime / 1000), '%Y%m') as months,count(1) as count from IrQuerydetail GROUP BY months;
</select>
</mapper>
查了全项目 resultType id 没重复,全项目 select id 也没重复,全项目 xml 文件没有重复多余
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.