2017-07-04 70 views
0

我想創建一個JHipster生成器來爲生成的項目設置Axon2。JHipster生成器:addMavenDependency沒有定義

爲了一個Java庫添加到項目I'using功能 addMavenDependencyindex.js

try { 
      addMavenDependency('org.axonframework', 'axon-integration', '2.4.6',''); 
    }catch (e) { 

,但我收到以下錯誤:

ERROR! 
Problem when adding the new libraries in your pom.xml 
You need to add manually: 

"org.axonframework:axon-integration": "2.4.6", 
ReferenceError: addMavenDependency is not defined 

任何幫助將是非常感謝。

+0

您是否嘗試過derefencing'this'這樣。 addMavenDependency()? –

回答

0

您需要延長BaseGenerator並致電this.addMavenDependency()

除非您與其他發電機組成,那麼你可以傳遞一個對象,與變量和函數來填充正在使用發電機像這樣:

const jhipsterVar = { moduleName: 'your-module' }; 
const jhipsterFunc = {}; 

module.exports = generator.extend({ 

    initializing: { 

     compose() { 
      this.composeWith('other-module', 
       { jhipsterVar, jhipsterFunc }, 
       this.options.testmode ? { local: require.resolve('generator-jhipster/generators/modules') } : null 
      ); 
     } 
    }, 

    writing: { 
     jhipsterFunc.addMavenDependency('com.test', 'test', '1.0.0'); 
    } 
});