如何获取 Spring 3.1.1 适用于 App Engine 数据存储



请大家给我看一个教程,介绍如何让Spring 3.1.1在Google App Engine上运行?

我已经遵循了几个教程,并设法让死的简单HelloWorld示例在App Engine上运行。但是,当我走得更远时,我停留在 Spring 和数据存储之间的持久进程。我也看了这个线程在Spring 3.1中配置JDO?,但它适用于本地主机,但由于javax.nameing.NamingException,当我部署到应用程序引擎时它不起作用。

因此,我正在寻找一个不太简单的教程,涵盖现实生活中应用程序的基本方面,如视图、模型和数据库。

Jappstart 是查看使用 Spring 和数据存储(通过 JPA)的 GAE 工作示例的好地方,也是构建基本 GAE/J 应用程序的良好起点。

花了大约一天的时间尝试完成这项工作,我想我会在这里添加一些额外的有用信息。首先看看这个项目 https://github.com/hleinone/spring-gae-jdo 和这个问题: http://code.google.com/p/googleappengine/issues/detail?id=1240 -- 评论 24 是有用的。

如果有人想使用注释驱动的配置来使用它,这是我是如何做到的:

package com.domain.yourcode.configuration;
import javax.jdo.JDOHelper;
import javax.jdo.PersistenceManagerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.orm.jdo.GAETransactionAwarePersistenceManagerFactoryProxy;
import org.springframework.orm.jdo.JdoTransactionManager;
//import org.springframework.orm.jdo.TransactionAwarePersistenceManagerFactoryProxy;
@Configuration
public class JDOConfiguration {
    private static final PersistenceManagerFactory pmf =     JDOHelper.getPersistenceManagerFactory("transactions-optional");
    @Bean
    public GAETransactionAwarePersistenceManagerFactoryProxy proxyPmf() {
        GAETransactionAwarePersistenceManagerFactoryProxy proxy = 
                new GAETransactionAwarePersistenceManagerFactoryProxy();
        proxy.setTargetPersistenceManagerFactory(pmf);
        proxy.setAllowCreate(false);
        return proxy;
    }
    @Bean
    public JdoTransactionManager transactionManager() {
        JdoTransactionManager mgr = new JdoTransactionManager();
        mgr.setPersistenceManagerFactory(pmf);
        return mgr;
    }
}

您仍然希望在应用程序上下文中<tx:annotation-driven/>.xml

相关内容

最新更新