我正在尝试通过读取yaml文件并将这些资源属性传递给堆栈类,使用AWS CDK Java为多个AWS资源构建堆栈。
private void generateCfn(List<ResourceTemplate> resourceList, TfConfiguration tfConfiguration) {
App app = new App();
new CfnGenerateStack(app,"CfnStack",null, resourceList,tfConfiguration);
app.synth();
}
资源列表和tfConfiguration包含AWS资源构建/创建所需的所有详细信息(例如,vpc名称,cidr,标签)
public class CfnGenerateStack extends Stack {
public CfnGenerateStack(final Construct parent,final String id, final StackProps props, List<ResourceTemplate> resourceList, TfConfiguration tfConfiguration) {
super(parent, id, props);
for(int i=0;i<resourceList.size();i++){
if(resourceList.get(i) instanceof Vpc) {
Vpc vpc=(Vpc)resourceList.get(i);
software.amazon.awscdk.services.ec2.Vpc myvpc = software.amazon.awscdk.services.ec2.Vpc.Builder.create(this, vpc.getName())
.cidr(vpc.getVariables().get("vpc_dev_cidr"))
.enableDnsHostnames(Boolean.parseBoolean(vpc.getEnable_dns_hostnames()))
.enableDnsSupport(Boolean.parseBoolean(vpc.getEnable_dns_support()))
.build();
我运行代码,然后尝试在命令行中运行命令“ cdk deploy”,出现以下错误:
cdk deploy
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:3.0.0:java (default-cli) on project cda: The parameters 'mainClass' for goal org.codehaus.mojo:exec-maven-plugin:3.0.0:java are missing or invalid -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:exec-maven-plugin:3.0.0:java (default-cli) on project cda: The parameters 'mainClass' for goal org.codehaus.mojo:exec-maven-plugin:3.0.0:java are missing or invalid
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:498)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.apache.maven.plugin.PluginParameterException: The parameters 'mainClass' for goal org.codehaus.mojo:exec-maven-plugin:3.0.0:java are missing or invalid
能请你帮忙吗?