一、Maven多模块项目编译失败:程序包xxx不存在

项目结构如下:(pom.xml)

parent(父类工程)

| - - - - - common(通用工具类子工程)

| - - - - - projectA(springboot子工程,依赖common工程)

问题描述:

通过parent父工程进行Maven install,parent父工程和common子工程打包成功,projectA子工程打包失败并报错

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project projectA: Compilation failure
[ERROR] /xxxx.java:[14,36] 程序包com.xxx.xxx.utils不存在

注意:就算projectA能打包成功,运行后调用,也会报common下的类找不到异常,为同一问题
解决办法:

在common子工程下的pom.xml,添加以下配置

1
2
3
4
5
6
7
8
9
10
11
 <build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<classifier>exec</classifier>
</configuration>
</plugin>
</plugins>
</build>

原因分析:

common也是SpringBoot工程,SpringBoot工程打包编译时,会生成两种jar包,一种是普通的jar,另一种是可执行jar。

默认情况下,这两种jar的名称相同,在不做配置的情况下,普通的jar先生成,可执行jar后生成,造成可执行jar会覆盖普通的jar。而projectA工程无法依赖common工程的可执行jar,所以编译失败:程序包xxx不存在。

解决方式二

在父工程(guli_parent)的 pom.xml 文件中把以下内容删除,即可解决问题

image-20210227203709221

删除之后:

1
2
3
4
5
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.1.18.RELEASE</version>
</plugin>

二、Vue 添加页面element-ui 组件报错

报错信息:[Vue warn]: Invalid prop: type check failed for prop “min”. Expected Number, got String.

image-20210303224213233

出错位置:

1
2
3
<el-form-item label="排序" prop="sort">
<el-input-number v-model="person.sort" controls-position="right" min="0" />
</el-form-item>

修改为:

1
2
3
<el-form-item label="讲师排序" prop="sort">
<el-input-number v-model="teacher.sort" controls-position="right" :min="0" />
</el-form-item>

三、Reason: Failed to determine a suitable driver class错误分析

报错


APPLICATION FAILED TO START


Description:

Failed to configure a DataSource: ‘url’ attribute is not specified and no embedded datasource could be configured.

Reason: Failed to determine a suitable driver class

Action:

Consider the following:
If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).

解决方式:

删除父工程中的:

image-20210321215445391

修改以下的代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
</resources>
</build>

image-20210321215619382

注意: 这个Bug 在我这试了很多次,都是失败。记得给项目模块 maven clean 一下,重新打包

四、aliyun-sdk-vod-upload引入报错解决办法

打开链接,去阿里云官网下载

https://help.aliyun.com/document_detail/51992.html?spm=a2c4g.11186623.6.1029.2dab6cecZfMGvO

如图下载

image-20210320223128094

解压缩文件

image-20210320223246742

CMD回车,进入控制台安装到仓库

image-20210320223321785

1
mvn install:install-file -DgroupId=com.aliyun -DartifactId=aliyun-sdk-vod-upload -Dversion=1.4.13 -Dpackaging=jar -Dfile=aliyun-java-vod-upload-1.4.13.jar

安装成功

image-20210320223418673

安装依赖

1
2
3
4
5
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-sdk-vod-upload</artifactId>
<version>1.4.13</version>
</dependency>

五、引入NUXT vue-awesome-swiper 插件出错

报错:

ERROR Could not compile template E:\IDEA\OnlineEduProject-Web\guli_front\node_modules\@nuxt\vue-app\template\App.js: Cannot resolve “swiper/dist/css/swiper.css” from “E:\IDEA\OnlineEduProject-Web\guli_front\swiper\dist\css\swiper.css”

at node_modules@nuxt\builder\dist\builder.js:723:17
at async Promise.all (index 0)
at async Builder.compileTemplates (node_modules@nuxt\builder\dist\builder.js:701:5)
at async Builder.generateRoutesAndFiles (node_modules@nuxt\builder\dist\builder.js:388:5)
at async Builder.build (node_modules@nuxt\builder\dist\builder.js:319:5)
at async Object._buildDev (node_modules@nuxt\cli\dist\cli-dev.js:107:5)
at async Object.startDev (node_modules@nuxt\cli\dist\cli-dev.js:65:7)
at async Object.run (node_modules@nuxt\cli\dist\cli-dev.js:52:5)
at async NuxtCommand.run (node_modules@nuxt\cli\dist\cli-index.js:413:7)

image-20210323162346286

解决方式:

原因: 使用 swiper 版本有官方有细微的调整

image-20210323170948372

官方提示:

image-20210323171024445

nuxt.config.js 把原有的 css 位置修改为新版的位置和nuxt-swiper-plugin.js 需要修改

详细请参考官方文档:https://github.com/surmon-china/vue-awesome-swiper

原:

nuxt-swiper-plugin.js

image-20210323171126526

nuxt.config.js

image-20210323170331026

修改为:

nuxt-swiper-plugin.js

1
2
3
4
import Vue from 'vue'
import VueAwesomeSwiper from 'vue-awesome-swiper'

Vue.use(VueAwesomeSwiper)

nuxt.config.js:

1
2
3
4
5
6
7
8
9
module.exports = {

// some nuxt config...
plugins: [
{ src: '~/plugins/nuxt-swiper-plugin.js', ssr: false }
],
css: [
'swiper/dist/css/swiper.css'
],

image-20210323170354005

配置好以后启动:

image-20210323171247297

六、数据添加类型错误

报错:

org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.ReflectionException: Could not set property ‘id’ of ‘class com.oy.guli.eduorder.entity.TOrder’ with value ‘1378706890791419905’ Cause: java.lang.IllegalArgumentException: argument type mismatch

image-20210404215439931

解决方式:

  • 检查entity类 下的 bean

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value="TOrder对象", description="订单")
public class TOrder implements Serializable {

private static final long serialVersionUID = 1L;

@TableId(value = "id", type = IdType.ID_WORKER)
private String id;

@ApiModelProperty(value = "订单号")
private String orderNo;

@ApiModelProperty(value = "课程id")
private String courseId;

@ApiModelProperty(value = "课程名称")
private String courseTitle;

@ApiModelProperty(value = "课程封面")
private String courseCover;

@ApiModelProperty(value = "讲师名称")
private String teacherName;

@ApiModelProperty(value = "会员id")
private String memberId;

@ApiModelProperty(value = "会员昵称")
private String nickname;

@ApiModelProperty(value = "会员手机")
private String mobile;

@ApiModelProperty(value = "订单金额(分)")
private BigDecimal totalFee;

@ApiModelProperty(value = "支付类型(1:微信 2:支付宝)")
private Integer payType;

@ApiModelProperty(value = "订单状态(0:未支付 1:已支付)")
private Integer status;

@ApiModelProperty(value = "逻辑删除 1(true)已删除, 0(false)未删除")
private Boolean isDeleted;

@ApiModelProperty(value = "创建时间")
private Date gmtCreate;

@ApiModelProperty(value = "更新时间")
private Date gmtModified;

}

修改

1
2
@TableId(value = "id", type = IdType.ID_WORKER_STR)
private String id;

image-20210404215750534

1
2
3
4
5
6
7
@ApiModelProperty(value = "创建时间")
@TableField(fill = FieldFill.INSERT)
private Date gmtCreate;

@ApiModelProperty(value = "更新时间")
@TableField(fill = FieldFill.INSERT_UPDATE)
private Date gmtModified;

image-20210404215845683

七、spring cloud gateway与spring-boot-starter-web冲突报错

报错:


APPLICATION FAILED TO START


Description:

Parameter 3 of constructor in com.oy.gateway.handler.ErrorHandlerConfig required a bean of type ‘org.springframework.http.codec.ServerCodecConfigurer’ that could not be found.

Action:

Consider defining a bean of type ‘org.springframework.http.codec.ServerCodecConfigurer’ in your configuration.

原因: 跟自己的maven 工程的依赖相关。需要去除对pom 父工程中 web 的依赖

解决方式:

在 gateway 工程的pom 中 进行细微的修改

1
2
3
4
5
6
7
8
9
10
11
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<!-- Maven整个生命周期内排除内置容器,排除内置容器导出成war包可以让外部容器运行spring-boot项目-->
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>