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

  • Post author:
  • Post category: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联系



版权声明:本文为a1194821568原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。