我一直在使用一些Yeoman Generators来提示我输入用户。我喜欢把输入放在JSON文件中。我可以看到String str = (String) table.getItem(itemId);
之后生成yo-rc.json
,但我想使用它(或类似文件)作为Yeoman的输入。
使用JHipster的示例:
$ yo jhipster
Welcome to the JHipster Generator v2.16.1
? (1/15) What is the base name of your application? (jhipster) helpme
? (2/15) What is your default Java package name? com.mycompany.helpme
...
# Yeoman Generator creates project via user inputs
$ cat my-custom.json
{
"generator-jhipster": {
"baseName": "helpme",
"packageName": "com.mycompany.helpme",
...
$ yo jhipster --file my-custom.json
...
# Yeoman Generator creates project via input file
听起来我应该能够利用Yeoman Storage API,但我个人没有成功地使用这条路线,也找不到任何相似的例子。
接下来,我想生成一些自发的实体,每个(https://jhipster.github.io/managing_relationships.html)具有复杂的关系。我发现这是一个两步过程:
./.jhipster/MyEntity.json
yo jhipster:entity MyEntity.json
答案 0 :(得分:2)
Jhipster已经看到了我对你的问题的评论。 下面是jhipster读取.yo-rc.json的地方,如果你真的想要任何其他名字也可以这样做,你只需要使用文件api读取该文件,但我建议你保留你的json命名.yo- rc.json兼容性
来自app / index.js的代码
this.baseName = this.config.get('baseName');
this.packageName = this.config.get('packageName');
this.authenticationType = this.config.get('authenticationType');
this.clusteredHttpSession = this.config.get('clusteredHttpSession');
this.searchEngine = this.config.get('searchEngine');
this.websocket = this.config.get('websocket');
this.databaseType = this.config.get('databaseType');
if (this.databaseType == 'mongodb') {
this.devDatabaseType = 'mongodb';
this.prodDatabaseType = 'mongodb';
this.hibernateCache = 'no';
} else if (this.databaseType == 'cassandra') {
this.devDatabaseType = 'cassandra';
this.prodDatabaseType = 'cassandra';
this.hibernateCache = 'no';
} else { // sql
this.devDatabaseType = this.config.get('devDatabaseType');
this.prodDatabaseType = this.config.get('prodDatabaseType');
this.hibernateCache = this.config.get('hibernateCache');
}
this.useCompass = this.config.get('useCompass');
this.javaVersion = this.config.get('javaVersion');
this.buildTool = this.config.get('buildTool');
this.frontendBuilder = this.config.get('frontendBuilder');
this.rememberMeKey = this.config.get('rememberMeKey');
this.enableTranslation = this.config.get('enableTranslation'); // this is enabled by default to avoid conflicts for existing applications
this.packagejs = packagejs;