使用Micronaut CLI创建应用程序,控制器

时间:2020-10-01 16:23:35

标签: java micronaut

Micronaut CLI在创建应用程序时非常有用,但是CLI中没有用于创建控制器的命令。

Micronaut Version: 2.0.3

在micronaut文档中,我们有一个用于配置文件https://docs.micronaut.io/2.0.0.M3/guide/index.html#cli的命令

$ mn profile-info service
Profile: service
------------------
The service profile

Provided Commands:
--------------------
  create-bean              Creates a singleton bean
  create-client            Creates a client interface
  create-controller        Creates a controller and associated test
  create-job               Creates a job with scheduled method
  create-test              Creates a simple test for the project's testing framework
  create-websocket-client  Creates a Websocket client
  create-websocket-server  Creates a Websocket server
  help                     Prints help information for a specific command


Provided Features:
------------------
...

运行命令mn profile-info service时出现错误消息

enter image description here

我只有以下选项

enter image description here

我正在尝试从cli创建一个控制器

1 个答案:

答案 0 :(得分:0)

配置文件仅在Micronaut 1.x版中。因此,与mn profile-info service之类的与配置文件相关的命令在Micronaut 2.x版中不可用。

在创建项目末尾时,请输入项目目录,您可以使用以下其他mn命令:

  • feature-diff-生成原始项目与具有其他功能的原始项目的差异。
  • create-job-使用计划的方法创建工作
  • create-client-创建一个客户端界面
  • create-controller-创建控制器和关联的测试
  • create-test-为项目的测试框架创建一个简单的测试
  • create-bean-创建一个单例bean
  • create-websocket-client-创建一个Websocket客户端
  • create-websocket-server-创建一个Websocket服务器

使用-h选项调用该命令时,您还可以查看该命令的更多说明。例如:

$ mn create-controller -h
Usage: mn create-controller [-fhvVx] CONTROLLER-NAME
Creates a controller and associated test
      CONTROLLER-NAME   The name of the controller to create
  -f, --force           Whether to overwrite existing files
  -h, --help            Show this help message and exit.
  -v, --verbose         Create verbose output.
  -V, --version         Print version information and exit.
  -x, --stacktrace      Show full stack trace when exceptions occur.
相关问题