1058. Failed to execute goal org.codehaus.mojo:exec-maven-plugin:3.1.0:exec (default-cli) on project

Solution: Failed to execute goal org.codehaus.mojo:exec-maven-plugin:3.0.0:exec (default-cli) on project spring_aop: Command execution failed.The problem h2>

Add the following dependent plugins to the pom without changing the content

maven-compiler-plugin: used to compile Java files, specify the JDK version, etc. (I tried to change to 1.8.0, it didn’t seem to work and then changed to 1.6.0)
exec-maven-plugin: used to execute the class file, where the path of the execution class needs to be specified in the 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>

Replenish:
Use mybatis-plus to automatically generate the framework

pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.7.12</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.example</groupId>
    <artifactId>x-admin</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>x-admin</name>
    <description>x-admin</description>
    <properties>
        <java.version>1.8</java.version>
    </properties>
    <dependencies>
        <!-- web -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <!-- mysql -->
        <dependency>
            <groupId>com.mysql</groupId>
            <artifactId>mysql-connector-j</artifactId>
        </dependency>
        <!-- mybatis-plus -->
        <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-boot-starter</artifactId>
            <version>3.5.2</version>
        </dependency>
        <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-generator</artifactId>
            <version>3.5.2</version>
        </dependency>
        <!-- freemarker -->
        <dependency>
            <groupId>org.freemarker</groupId>
            <artifactId>freemarker</artifactId>
        </dependency>
        <!-- lombok -->
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-redis</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

        <!-- fastjson -->
        <dependency>
            <groupId>com.alibaba.fastjson2</groupId>
            <artifactId>fastjson2</artifactId>
            <version>2.0.7</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-core</artifactId>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <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>

</project>

main method

package com.example.xadmin;

import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.config.OutputFile;
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;

import java.util.Collections;

public class CodeGenerator {
    public static void main(String[] args) {
        String url = "jdbc:mysql://localhost:3306/xdb?characterEncoding=UTF-8";
        String username = "root";
        String password = "123456";
        String moduleName = "sys";
        String mapperLocation = "D:\idea\x-admin\src\main\resources\mapper\" + moduleName;
        String tables = "x_user,x_role,x_menu,x_user_role,x_role_menu";

        FastAutoGenerator.create(url, username, password)
                .globalConfig(builder -> {
                    builder.author("tuomasi") // set the author
// .enableSwagger() // Enable swagger mode
// .fileOverride() // Overwrite generated files
                            .outputDir("D:\idea\x-admin\src\main\java"); // specify the output directory
                })
                .packageConfig(builder -> {
                    builder.parent("com.example") // set the parent package name
                            .moduleName(moduleName) // Set the parent package module name
                            .pathInfo(Collections.singletonMap(OutputFile.xml, mapperLocation)); // Set mapperXml generation path
                })
                .strategyConfig(builder -> {
                    builder.addInclude(tables) // Set the name of the table to be generated
                            .addTablePrefix("x_"); // Set filter table prefix
                })
                .templateEngine(new FreemarkerTemplateEngine()) // Use the Freemarker engine template, the default is the Velocity engine template
                .execute();
    }
}

application.yml

server:
  port: 9999

spring:
  datasource:
    username: root
    password: 123456
    url: jdbc:mysql://localhost:3306/xdb?characterEncoding=UTF-8
  redis:
    port: 6379
    host: localhost

record:
  level:
    com.example: debug

Effect: