2
我知道Roo並不是真的打算如何使用,但我打算用Roo敲一個快速演示程序在控制檯應用程序中運行。基本控制檯應用程序和Spring Roo
我已經創建了下面的袋鼠腳本一個基本的應用程序:通過添加下面的類
package com.xetius.maths;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class MathMain {
public static void main(String[] args) {
ApplicationContext appContext = new ClassPathXmlApplicationContext("applicationContext.xml");
System.out.println("Here");
}
}
我的計劃
project --topLevelPackage com.xetius.maths
persistence setup --provider HIBERNATE --database HYPERSONIC_IN_MEMORY
entity --class ~.domain.Equation --testAutomatically
field number --fieldName firstNum --type java.lang.Integer --notNull
field number --fieldName secondNum --type java.lang.Integer --notNull
field string --fieldName operator --notNull
field number --fieldName answer --type java.lang.Integer
接下來,我想添加一個基本的控制檯是firstNum傳遞,operator和secondNum,將這些添加到數據庫中,然後計算答案,將其添加到數據庫中,然後顯示響應。如果答案無法計算(例如除以0),則將事務重新放回。
這應該是非常簡單的,我猜是的,但是,我不能解決如何訪問sessionFactory。這是否隱含在別的東西中,還是我做錯了什麼?
我只是無法做到這一點,或者有另一種方式來做到這一點。這一切都是爲了一個演示,我的老闆展示Roo的優勢,但似乎無法讓我的頭圍繞該位