AWS cdk-cli 初始化 Java CDK

AWS DevOps Java About 2,428 words

命令

使用app模板初始化,指定java语言。

cdk init app --language java

输出

$ cdk init app --language java
Applying project template app for java
# Welcome to your CDK Java project!

This is a blank project for CDK development with Java.

The `cdk.json` file tells the CDK Toolkit how to execute your app.

It is a [Maven](https://maven.apache.org/) based project, so you can open this project with any Maven compatible Java IDE to build and run tests.

## Useful commands

 * `mvn package`     compile and run tests
 * `cdk ls`          list all stacks in the app
 * `cdk synth`       emits the synthesized CloudFormation template
 * `cdk deploy`      deploy this stack to your default AWS account/region
 * `cdk diff`        compare deployed stack with current state
 * `cdk docs`        open CDK documentation

Enjoy!

Initializing a new git repository...
warning: in the working copy of '.gitignore', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'README.md', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'cdk.json', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'pom.xml', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'src/main/java/com/myorg/MyCdkApp.java', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'src/main/java/com/myorg/MyCdkStack.java', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'src/test/java/com/myorg/MyCdkTest.java', LF will be replaced by CRLF the next time Git touches it
Executing 'mvn package'
'mvn' is not recognized as an internal or external command,
operable program or batch file.

注意

app为固定值。如果传入自定义的值,会报错。

$ cdk init myapp
Available templates:
* app: Template for a CDK Application
   └─ cdk init app --language=[csharp|fsharp|go|java|javascript|python|typescript]
* lib: Template for a CDK Construct Library
   └─ cdk init lib --language=typescript
* sample-app: Example CDK Application with some constructs
   └─ cdk init sample-app --language=[csharp|fsharp|go|java|javascript|python|typescript]
****************************************************
*** Newer version of CDK is available [2.1143.0] ***
*** Upgrade recommended (npm install -g aws-cdk) ***
****************************************************
Unknown init template: myapp

文档

cdk docs
Views: 7 · Posted: 2026-10-28

———         Thanks for Reading         ———

Give me a Star, Thanks:)

https://github.com/fendoudebb/LiteNote

扫描下方二维码关注公众号和小程序↓↓↓

扫描下方二维码关注公众号和小程序↓↓↓
Prev Post
Today In History
Browsing Refresh