使用 mvn compile exec:java 编译java项目 报错

错误1描述:当新建一个maven项目添加logger日志后,启动main方法时报错

main方法:

package com.help.demo;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class Tutorial {
	private static final transient Logger log = LoggerFactory.getLogger(Tutorial.class);

	public static void main(String[] args) {
	
	        log.info("My First Apache Shiro Application");
	        System.exit(0);
	}

}

控制台报错:

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.

解决办法:我的这边是引入的依赖有问题,将依赖改变成下面的,错误消失

        <dependency>
	       <groupId>org.slf4j</groupId>
	       <artifactId>slf4j-nop</artifactId>
	       <version>1.7.2</version>
	   </dependency>

错误2描述:在cmd窗口进入项目的目录后利用 mvn compile exec:java 编译 报错
在这里插入图片描述

错误输出

[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.6.0:java (d
efault-cli) on project shiro-tutorial: The parameters 'mainClass' for goal org.c
odehaus.mojo:exec-maven-plugin:1.6.0:java are missing or invalid -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit
ch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please rea
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginParamete
rException

解决办法:我的这边是因为没有找到main方法的主类
在这里插入图片描述

本人只是为了记录自己的经历,如果侵犯到您的权益 ,请与1194821568@qq.com联系

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值