1。问题描述 h3>
利用maven导包,运行Mybatis案例的主要函数时报的错。 p>
[ERROR] 执行目标org.codehaus.mojo:exec-maven-plugin:1.6.0:exec (default-cli)项目mybatis_annotation:命令执行失败。:进程退出错误:1(退出值:1)->
[ERROR]
[ERROR]要查看错误的完整堆栈跟踪,请使用-e开关重新运行Maven。
[ERROR]使用-X开关重新运行Maven以启用完整的调试日志记录。
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException。
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException引用>
2。解决办法(三种可参考的方法) h3>
方法一:<字体>在pom.xm中添加以下内容——<代码> exec-maven-plugin 代码> font> h5>
<build> <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> <version>1.6.0</version> <!-- <executions>--> <!-- <execution>--> <!-- <goals>--> <!-- <goal>java</goal>--> <!-- </goals>--> <!-- </execution>--> <!-- </executions>--> <configuration> <classpathScope>test</classpathScope> <!-- <mainClass>com.itheima.test.MybatisTest</mainClass>--> </configuration> </plugin> </plugins> </build>
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
here
. 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-pluginis concerned here
4. Call database Chinese garbled code problem1. 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<properties> <!-- 文件拷贝时的编码 --> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <!-- 编译时的编码 --> <maven.compiler.encoding>UTF-8</maven.compiler.encoding> </properties>
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 >
compile
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.test
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:
- Failed to execute goal org.codehaus.mojo:exec-maven-plugin:3.0.0:exec (default-cli) on project Hello
- How to Solve Error: Failed to execute goal org.codehaus.mojo:……..
- [Solved] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.2:test
- 解决Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile
- Failed to execute goal org.apache.maven.plugins:maven-gpg-plugin:1.6:sign
- Failed to execute goal org.apache.maven . plugins:maven-surefire-plugin :2.12.4:test
- How to Fix Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile
- [ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.2:war (default-war) on pr
- RocketMQ Failed to execute goal org.apache.maven.plugins:maven-checkstyle-plugin:2.17:check…
- Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.1:test (default-test)
- Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile)
- Failed to execute goal org.apache.maven.plugins:maven-javadoc-plugin:2.9.1:jar (default) on project
- Failed to execute goal org.apache.tomcat.maven:tomcat7-maven-plugin:2.2:run (default-cli) on project
- Failed to execute goal org.apache.tomcat . maven:tomcat7-maven-plugin : 2.2: run solution
- Failed to execute goal org.apache.maven . plugins:maven-clean-plugin :2.6.1:cle
- Failed to execute goal org.apache.maven.plugins:maven-clean-plugin:3.0.0:clean (default-clean) on
- Failed to execute goal in Maven build org.apache.tomcat .maven:
- Error: Failed to execute goal org.mybatis.generator:mybatis-generator-maven-plugin:1.3.2
- Failed to execute goal com.spotify:docker-maven-plugin:1.0.0:build Exception caught: basedir src/mai
- Failed to execute goal org.apache.maven.p1ugins:maven-clean-p1ugin:2.5:clean (default-clean)