代码之家  ›  专栏  ›  技术社区  ›  San Jaisy

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

  •  0
  • San Jaisy  · 技术社区  · 5 年前

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

    Micronaut Version: 2.0.3
    

    从micronaut文档中,我们有一个profile命令 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创建控制器

    0 回复  |  直到 5 年前
        1
  •  0
  •   cgrim    5 年前

    配置文件仅在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.