Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.6.0



[ERROR] 执行目标org.codehaus.mojo:exec-maven-plugin:1.6.0:exec (default-cli)项目mybatis_annotation:命令执行失败。:进程退出错误:1(退出值:1)->
[ERROR] [Help 1]

[ERROR] [Help 1]


方法一:<字体>在pom.xm中添加以下内容——<代码> exec-maven-plugin

<!--                <executions>-->
<!--                    <execution>-->
<!--                        <goals>-->
<!--                            <goal>java</goal>-->
<!--                        </goals>-->
<!--                    </execution>-->
<!--                </executions>-->
<!--                    <mainClass>com.itheima.test.MybatisTest</mainClass>-->

annotation section can not add

method 2: modify code

note: this error will sometimes occur after adding ** check the code section of the main function for errors. ** if the resource is closed before the method is called, etc.

method three: reference source inside the. Idea file to replace their own creation maven project. Idea file.

can also solve the problem of confused Chinese code, which can be seen as the reason for the initial configuration of idea. I haven’t found the specific configuration method yet, please inform me if there are specific configuration change steps or other reasons. Thanks for


. Analyze the reason

I replaced the main function with @test to run the Test method. The code can run normally, but it still won’t work if I replace it with the main function again. Two plugins need to be introduced here: maven-compiler-plugin and Exec-Maven-Plugin.
**maven-compiler-plugin: ** compiling Java code, you can specify the JDK version of the project source code, the compiled JDK version, and the code
exec-maven-plugin : to execute the class file, where the plug-in configuration should specify the path to execute the class. Only the exec-maven-plugin

is concerned here
4. Call database Chinese garbled code problem

1. The first type: in setting-> maven-> Runner-> VM Options
enter -dfile.encoding =gb2312
the first method is not bad, and the second method is not good, but I think it will be used in other places, code here first
2. The second type: po. XML type to add

	<!-- 文件拷贝时的编码 -->
	<!-- 编译时的编码 -->

5. Internal label analysis

1.< goal > The exec consists of two goals :exec :exec and exec: Java. How should you choose?First, you need to remember that exec:exec is always more powerful and flexible than ExEC: Java, except that the main difference between the two is in thread management: Exec: Exec always starts a new thread and exits (closes the application) from the VM when only daemon threads are left. For exec: Java, when all non-daemon threads terminate, the daemon thread is interrupted by Joine or interrupt and should not be closed. But for the average user, the difference doesn’t matter. For both options, in general, if your project is very easy to start without setting JVM parameters, system properties, or command-line arguments, use exec: Java,

2.< classpathScope >

is compile by default, so we don’t configure anything, so we just mean compile. Compile means that the dependent project needs to participate in the compilation of the current project. Of course, subsequent tests, the run cycle also participate in the compilation, so it is a strong dependency. When packing, you usually need to include it.

scope for test indicates that the dependent project only participates in test-related work, including compiling and executing the test code. Typical examples are junit.

Runntime indicates that the dependent project does not need to participate in compiling the project, but it does need to participate in the later test and run cycles. Compared to compile, we skip compilation, which, frankly, isn’t very different from compile in terminal projects (non-open source, internal enterprise systems). Relatively common implementation such as JSR×××, the corresponding API JAR is compile, the specific implementation is runtime, compile only needs to know the interface is enough. A good example is the Oracle JDBC driver package, which generally has a scope of runntime. In addition, the dependency of runntime is usually used with optional, which is true. I can do it with A, or I can do it with B.

Provided provided means you can package it without having to package it, and other facilities (Web Container) provide it. In fact, this dependency can theoretically be involved in compiling, testing, running, and so on. So we compile, but we do exclude in the packaging phase.

In terms of engagement, it also provides the same. However, dependencies are not captured from maven repository, but from local file system, which must be used with the systemPath attribute.

Read More: