Acceleo_新建与运行

1 File->New->Acceleo project(填写项目名称,其它默认);

2 Next->选择Metamodel URIs(需要现在的工作空间中包含元模型)->在添加时选择Runtime Version->选中Generate documentation/Generate file/Main template->finish

3 编写*.mtl文件

4 运行报错:

Exception in thread "main" org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1DiagnosticWrappedException: org.eclipse.emf.ecore.xmi.PackageNotFoundException: Package with uri 'http://www.example.org/uilm' not found. (file:/E:/eclipseworkspace/Acceleo/org.eclipse.acceleo.module.sample/Trans/inModel.xmi, 8, 18)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.handleDemandLoadException(ResourceSetImpl.java:319)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoadHelper(ResourceSetImpl.java:278)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResource(ResourceSetImpl.java:406)
at org.eclipse.acceleo.common.utils.ModelUtils.load(ModelUtils.java:391)
at org.eclipse.acceleo.common.utils.ModelUtils.load(ModelUtils.java:356)
at org.eclipse.acceleo.engine.service.AbstractAcceleoGenerator.initialize(AbstractAcceleoGenerator.java:488)
at org.eclipse.acceleo.module.sample.main.Generate.<init>(Generate.java:90)

at org.eclipse.acceleo.module.sample.main.Generate.main(Generate.java:144)

原因:在本项目中没有包含uilm.ecore元模型

解决办法:New->Folder->将uilm.ecore拷贝到该文件夹中

5 运行出错:

The generation failed to generate any file because there are no model elements that matches at least the type of the first parameter of one of your main templates. 

The problem may be caused by a problem with the registration of your metamodel, please see the method named "registerPackages" in the Java launcher of your generator. It could also come from a missing [comment @main/] 

in the template used as the entry point of the generation. 

原因:

代码中缺少[comment @main/] 

原来代码为:

[comment encoding = UTF-8 /]
[**
 * The documentation of the module generate.
 */]
[module generate('http://www.example.org/uilm')]
[**
 * The documentation of the template generateElement.
 * @param aDirection
 */]

[template public generateElement(aWinApplication : WinApplication)]

...........................................后面是具体转换

修改后代码为:

[comment encoding = UTF-8 /]
[**
 * The documentation of the module generate.
 */]
[module generate('http://www.example.org/uilm')]
[**
 * The documentation of the template generateElement.
 * @param aDirection
 */]
[template public generateElement(aWinApplication : WinApplication)]

[comment @main/]

...........................................运行成功

6 运行配置:

Project:项目名称

Main class:项目名称.main.Generate

Model:输入模型(*.xml)

Target:生成文件的位置

Runner:Java Application





  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值