简体   繁体   English

执行 mvn archetype:generate with User Input from Java 代码

[英]Execute mvn archetype:generate with User Input from Java Code

I am creating a project from a custom archetype in Spring Boot Here are the steps我正在从 Spring Boot 中的自定义原型创建一个项目这里是步骤

  1. Created a Template Project创建了一个模板项目

  2. Executed mvn archetype:create-from-project -Darchetype.properties=../myCustom.properties command from Java Code and created a custom archetype from template从 Java 代码执行mvn archetype:create-from-project -Darchetype.properties=../myCustom.properties命令并从模板创建自定义原型

  3. Installed custom archetype into Local maven Repo.将自定义原型安装到本地 maven 存储库中。 cd target\generated-sources\archetype mvn clean install cd target\generated-sources\archetype mvn clean install

  4. Create project from Custom Archetype (This is the problem area) mvn archetype:generate -DarchetypeGroupId=com.mycompany -DarchetypeArtifactId=myApp-template-archetype -DarchetypeVersion=1.0.0-SNAPSHOT -Ddomain="archetypeDomain"从自定义原型创建项目(这是问题区域) mvn archetype:generate -DarchetypeGroupId=com.mycompany -DarchetypeArtifactId=myApp-template-archetype -DarchetypeVersion=1.0.0-SNAPSHOT -Ddomain="archetypeDomain"

So till point 3, I am able to execute commands from Java Project.所以直到第 3 点,我能够执行来自 Java 项目的命令。

The maven command in #4., Java Code remains stuck and does not prompt user input. #4.中的maven命令,Java代码卡住,不提示用户输入。 However, we execute the same command ( mvn archetype:generate ) from Command Prompt, it asks user input (which is expected and desired).但是,我们从命令提示符执行相同的命令( mvn archetype:generate ),它要求用户输入(这是预期的和期望的)。

Now, I am not getting any idea on why the Java application does not prompt for user input but in command prompt it does.现在,我不知道为什么 Java 应用程序不提示用户输入,但在命令提示符下却提示。

Thanks in Advance.. !提前致谢.. !

I managed to execute the command using following parameters我设法使用以下参数执行命令

mvn archetype:generate -DarchetypeGroupId=com.mycompany -DarchetypeArtifactId=myApp-template-archetype -DarchetypeVersion=1.0.0-SNAPSHOT -Ddomain="archetypeDomain" -DinteractiveMode=false

By running the above command, I managed to took get it worked.通过运行上面的命令,我设法让它工作了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM