idea编译项目突然报错
IDEA编译项目一直报java: 找不到符号 符号: 方法 getUserId()异常 或者打包总是找不到类 但是类明明存在
网上百度了很多帖子 都说是lombok问题 或者是lombok 版本问题 其实不是
解决办法是发现IDEA没有走指定的maven 走的是默认 C:\Users\Administrator\.m2 路径下的maven
解决办法:直接删除 C:\Users\Administrator\m2 默认文件夹即可 记得刷新项目哦
记录解决第二个问题 :
在maven构建项目时候发现跟本地Idea编译项目时不一致!表现为
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.1.0.RELEASE)
2021-07-30 19:14:18.440 INFO 29177 --- [ main] com.tianju.smdk.TjServerApplication : Starting TjServerApplication v0.0.1-SNAPSHOT on iZf8zf4p0dwlnk7o9xms5cZ with PID 29177 (/home/admin/app/project/tj_server-0.0.1-SNAPSHOT.jar started by root in /root)
2021-07-30 19:14:18.441 INFO 29177 --- [ main] com.tianju.smdk.TjServerApplication : No active profile set, falling back to default profiles: default
Fri Jul 30 19:14:19 CST 2021 org.springframework.boot.loader.LaunchedURLClassLoader@49c2faae JM.Log:INFO Init JM logger with Slf4jLoggerFactory success, org.springframework.boot.loader.LaunchedURLClassLoader@49c2faae
Fri Jul 30 19:14:19 CST 2021 org.springframework.boot.loader.LaunchedURLClassLoader@49c2faae JM.Log:INFO Log root path: /root/logs/
Fri Jul 30 19:14:19 CST 2021 org.springframework.boot.loader.LaunchedURLClassLoader@49c2faae JM.Log:INFO Set nacos log path: /root/logs/nacos
2021-07-30 19:14:19.768 ERROR 29177 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
client error: invalid param. null
Action:
please check your client configuration
IDEA 本地编译为
Connected to the target VM, address: '127.0.0.1:61108', transport: 'socket'
11:28:02.444 [main] DEBUG cn.hutool.log.LogFactory - Use [Slf4j] Logger As Default.
11:28:02.446 [main] DEBUG com.tianju.smdk.TjServerApplication - 开始启动.........
/**
*
* @Author 小白
* @Email [email protected]
* @create 2021-07-23
* @company 杭州天剧网络科技有限公司
* // _ooOoo_
* // o8888888o
* // 88" . "88
* // (| -_- |)
* // O\ = /O
* // ____/`---'\____
* // .' \\| |// `.
* // / \\||| : |||// \
* // / _||||| -:- |||||- \
* // | | \\\ - /// | |
* // | \_| ''\---/'' | |
* // \ .-\__ `-` ___/-. /
* // ___`. .' /--.--\ `. . __
* // ."" '< `.___\_<|>_/___.' >'"".
* // | | : `- \`.;`\ _ /`;.`/ - ` : | |
* // \ \ `-. \_ __\ /__ _/ .-` / /
* // ======`-.____`-.___\_____/___.-`____.-'======
* // `=---='
* // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
* // 佛祖保佑 永无BUG
* //
* // .::::.
* // .::::::::.
* // :::::::::::
* // ..:::::::::::'
* // '::::::::::::'
* // .::::::::::
* // '::::::::::::::..
* // ..::::::::::::.
* // ``::::::::::::::::
* // ::::``:::::::::' .:::.
* // ::::' ':::::' .::::::::.
* // .::::' :::: .:::::::'::::.
* // .:::' ::::: .:::::::::' ':::::.
* // .::' :::::.:::::::::' ':::::.
* // .::' ::::::::::::::' ``::::.
* // ...::: ::::::::::::' ``::.
* // ```` ':. ':::::::::' ::::..
* // '.:::::' ':'````..
* //
* //
* // ┌─┐ ┌─┐ + +
* // ┌──┘ ┴───────┘ ┴──┐++
* // │ │
* // │ ─── │++ + + +
* // ███████───███████ │+
* // │ │+
* // │ ─┴─ │
* // │ │
* // └───┐ ┌───┘
* // │ │
* // │ │ + +
* // │ │
* // │ └──────────────┐
* // │ │
* // │ ├─┐
* // │ ┌─┘
* // │ │
* // └─┐ ┐ ┌───────┬──┐ ┌──┘ + + + +
* // │ ─┤ ─┤ │ ─┤ ─┤
* // └──┴──┘ └──┴──┘ + + + +
* 神兽保佑
* 代码无BUG!
*/
后来发现是maven找不到 resources 资源目录内的配置文件导致的
解决办法:这是找到资源的样子
找不到时候的样子
解决:将resources 变为资源目录即可
maven配置
<resources>
<!--Mybatis Mapper xml文件加载-->
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
<!--Maven打包加载资源文件路径-->
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.xml</include>
<include>*.properties</include>
<include>**/*.properties</include>
<include>**/*.yml</include>
<include>**/*.txt</include>
</includes>
</resource>
</resources>
重新编译maven 即可解决问题
第二个错误
Unable to find a single main class from the following candidates
解决办法
将父pom中的
<groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <version>2.5.3</version>
改为
groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId>
即可
错误三:
项目打包编译 一直报错等待
解决办法:检查父项目依赖
保证层级依赖即可 而不是直接依赖主工程fh_mall_service
记得删除 pom里面的
<relativePath/> 标签