如何使用Datanucleus+;PostgreSQL
我使用GWT和对Google数据存储的支持创建了一个应用程序,但现在我正在尝试将我的应用程序移动到我自己的服务器上,并且我还尝试将我的应用程序从Google app Engine和数据存储分离 更准确地说:我想停止使用Google数据存储,开始使用JDO和Datanucleus,但使用PostgreSQL(或其他关系数据库)。我尝试在Datanucleus.org中搜索,但没有简单的教程供我使用 拜托,有人能帮我吗 多谢各位!如何使用Datanucleus+;PostgreSQL,postgresql,gwt,google-cloud-datastore,datanucleus,Postgresql,Gwt,Google Cloud Datastore,Datanucleus,我使用GWT和对Google数据存储的支持创建了一个应用程序,但现在我正在尝试将我的应用程序移动到我自己的服务器上,并且我还尝试将我的应用程序从Google app Engine和数据存储分离 更准确地说:我想停止使用Google数据存储,开始使用JDO和Datanucleus,但使用PostgreSQL(或其他关系数据库)。我尝试在Datanucleus.org中搜索,但没有简单的教程供我使用 拜托,有人能帮我吗 多谢各位! =)我已经发现了如何做,尽管我认为这应该更容易些。 下面是: 1)
=)我已经发现了如何做,尽管我认为这应该更容易些。
下面是: 1) 首先我们必须设置PostgreSQL server 2) 使用webAppCreator(来自GWT SDK)创建我们的web应用程序 3) 因为我们必须增强域类,以便datanucleus和JDO使用它们,所以我们有多种选择。我使用了一个apacheant任务(来自googleappenginesdk)。如果我们这样做,我们可以使用app engine(简单的类增强)中的好部分,但我们的应用程序不会受到app engine的限制。
使用webAppCreator创建的build.xml的新增内容:
<!-- this refers to the location of my Google AppEngine SDK -->
<property name="sdk.dir" location="C:/Projects/appengine-java-sdk" />
<import file="${sdk.dir}/config/user/ant-macros.xml" />
<target name="copyjars"
description="Copies the App Engine JARs to the WAR.">
<copy
todir="war/WEB-INF/lib"
flatten="true">
<fileset dir="${sdk.dir}/lib/user">
<include name="**/*.jar" />
</fileset>
</copy>
</target>
<target name="compile" depends="copyjars"
description="Compiles Java source and copies other source files to the WAR.">
<mkdir dir="war/WEB-INF/classes" />
<copy todir="war/WEB-INF/classes">
<fileset dir="src">
<exclude name="**/*.java" />
</fileset>
</copy>
<javac
srcdir="src"
destdir="war/WEB-INF/classes"
classpathref="project.class.path"
debug="on" />
</target>
<target name="datanucleusenhance" depends="compile"
description="Performs JDO enhancement on compiled data classes.">
<enhance_war war="war" />
</target>
8) 创建一个PersistenceManagerFactory,如下所示:
File propsFile = new File("Insert the location of the properties file here");
PersistenceManagerFactory pmf = JDOHelper.getPersistenceManagerFactory(propsFile);
9) 创建域类并运行新的Ant目标datanucleusenhance
10) 这将创建增强的类和与关系数据库的连接,并将信息存储在PostgreSQL的表中
11) 如果我没有弄错,如果我没有忘记任何事情,就这样:)
谢谢你阅读这个问题。 如果你发现什么不对劲,能告诉我吗?这是我第一次来这里
===一些参考资料===
File propsFile = new File("Insert the location of the properties file here");
PersistenceManagerFactory pmf = JDOHelper.getPersistenceManagerFactory(propsFile);