How to Solve:Failed to execute goal org.codehaus.mojo:exec-maven-plugin:3.0.0:exec (default-cli) on project spring_aop: Command execution failed.
error
error:
Failed to execute goal org.codehaus.mojo:exec-maven-plugin:3.0.0:exec (default-cli) on project
spring_aop: Command execution failed.
Solution 1: in this case, I will use the main method to execute the program and use the unit test @ test instead
~It used to be like this: running with main
public class MyTest {
public static void main(String[] args) {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
//Dynamic proxies represent interfaces
UserService userservice = (UserService) context.getBean("userservice");
userservice.add();
}
}
~Changed to: use @ test
import com.niuyun.service.UserService;
import com.niuyun.service.UserServiceImpl;
import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class MyTest {
@Test
public void test(){
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
//Dynamic proxies represent interfaces
UserService userservice = (UserService) context.getBean("userservice");
userservice.add();
}
}
~Finish the work and run successfully
! Expansion
@Test is the basis of JUnit testing, and its functions are as follows:
1. Specify the type of exception to be thrown
2. Test the running time of the code.
Solution 2: if you have to use the main function, you can introduce two plug-ins in Maven (compiler can not be introduced), but it may lead to Chinese garbled.
Maven compiler plugin: used to compile java files, specify JDK version, etc.
exec Maven plugin: used to execute class files, in which the path of executing class should be indicated in plug-in configuration.
<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>
</configuration>
</plugin>
</plugins>
</build>
~Run successfully
Solve the problem of garbled code
Method 1:
in setting – & gt; maven-> Runner-> Fill in the column VM options
with – dfile. Encoding = GB2312
Method 2: add in pom.xml (I tried this method, but I didn’t solve the garbled code, which may be useful to you)
<properties> <!-- Encoding when copying files --> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <!-- Compile-time coding --> <maven.compiler.encoding>UTF-8</maven.compiler.encoding> </properties>
Read More:
- Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.6.0
- Failed to execute goal org.codehaus.mojo:exec-maven-plugin:3.0.0:exec (default-cli) on project Hello
- How to Fix Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile
- [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-gpg-plugin:1.6:sign
- Failed to execute goal in Maven build org.apache.tomcat .maven:
- Failed to execute goal org.apache.maven . plugins:maven-surefire-plugin :2.12.4:test
- Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.1:test (default-test)
- Error: Failed to execute goal org.mybatis.generator:mybatis-generator-maven-plugin:1.3.2
- [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-compiler-plugin:3.7.0:compile
- Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile)
- Failed to execute goal
- Failed to execute goal org.apache.tomcat . maven:tomcat7-maven-plugin : 2.2: run solution
- 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.maven.plugins:maven-clean-plugin:3.0.0:clean (default-clean) on
- 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 . plugins:maven-clean-plugin :2.6.1:cle