我正在尝试使用Maven与Aion创建Java合同,但是每次我尝试运行public class CourseModel {
public List<Course> mycourse{ get; set; }
public string StudentName {get; set;}
}
EF generated Class
public partial class Course
{
public Course()
{
this.Student= new HashSet<Student>();
}
public int CourseID { get; set; }
public string CourseName { get; set; }
i have inserted this field to check for checked value
public bool Ischecked { get; set; }
public virtual ICollection<Student> Student { get; set; }
}
public partial class Student
{
public Student()
{
this.Course= new HashSet<Course>();
}
public int StudentID { get; set; }
public string StudentName { get; set; }
public virtual ICollection<Course> Course{ get; set; }
}
public ActionResult Index()
{
CourseModel coursemodel = new CourseModel();
using (Entities db = new Entities())
{
coursemodel.mycourse = db.Course.ToList<Course>();
return View(coursemodel);
}
}
[HttpPost]
public ActionResult Index(CourseModel course)
{
return View(course);
}
View
@using (Html.BeginForm("index", "Course", FormMethod.Post))
<input type="Text" name="StudentName" placeholder="Name" />
{
<table>
@for (int i = 0 ; i < Model.mycourse.Count; i++)
{
if (i % 3 == 0) {
@:<tr></tr>
}
<div>
@Html.CheckBoxFor(x => x.mycourse[i].Ischecked)
<label>@Model.mycourse[i].CourseName</label>
@Html.HiddenFor(x => x.mycourse[i].CourseID)
@Html.HiddenFor(x => x.mycourse[i].CourseName)
</div>
}
</table>
<input type="submit" value="Submit" />
}
时,都会出现以下错误:
mvn clean install
我使用Maven构建命令[ERROR] Failed to execute goal org.aion4j:aion4j-maven-plugin:0.6.7:postpack (default) on project LearningAion: Contract Jar post compilation failed: InvocationTargetException: NullPointerException -> [Help 1]
重新创建了一个项目,该项目运行正常。
这是我的合同代码:
mvn archetype:generate -DarchetypeGroupId=org.aion4j -DarchetypeArtifactId=avm-archetype -DarchetypeVersion=0.20
根据Aion Docs,所有内容都应该编译。我不确定为什么该合同无效,但是当我创建一个全新的合同时。
答案 0 :(得分:1)
在项目的pom.xml
文件中查看<contract.main.class>
。仔细检查这两个标记之间的内容是您的主要Java类的名称和程序包名称。如果您将其设置为AnimalHouse.MyPets
。
<properties>
...
<contract.main.class>AnimalHouse.MyPets</contract.main.class>
...
</properties>