我正在为我想要实现购物功能的客户的网站工作。
我知道创建PayPal购物车真的很容易
但这个方法是否被Web开发人员接受,或者我应该寻找其他方法吗?
答案 0 :(得分:1)
是的,它已被接受。
package com.test.db;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
import org.springframework.transaction.PlatformTransactionManager;
import java.util.HashMap;
@Configuration
@EnableJpaRepositories(basePackages = "com.test.master", entityManagerFactoryRef = "userMasterEntityManager", transactionManagerRef = "userMasterTransactionManager")
public class MasterDBConfig {
@Bean
@Primary
public LocalContainerEntityManagerFactoryBean userMasterEntityManager() {
LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
em.setDataSource(dataSource());
em.setPackagesToScan(new String[] { "com.test.master" });
HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
em.setJpaVendorAdapter(vendorAdapter);
HashMap<String, Object> properties = new HashMap<>();
properties.put("hibernate.hbm2ddl.auto", "create");
properties.put("hibernate.id.new_generator_mappings", "false");
properties.put("hibernate.show_sql", "true");
properties.put("hibernate.dialect", "org.hibernate.dialect.MySQL5Dialect");
properties.put("hibernate.testOnBorrow", "true");
properties.put("hibernate.validationQuery", "SELECT 1");
properties.put("hibernate.testWhileIdle", "true");
// properties.put("hibernate.timeBetweenEvictionRunsMillis", "3600000");
properties.put("hibernate.connection.autoReconnect", "true");
properties.put("hibernate.connection.autoReconnectForPools", "true");
em.setJpaPropertyMap(properties);
return em;
}
@Primary
@Bean(name = "dataSource")
public DataSourceRouter dataSource() {
return new DataSourceRouter();
}
@Primary
@Bean
public PlatformTransactionManager userMasterTransactionManager() {
JpaTransactionManager transactionManager = new JpaTransactionManager();
transactionManager.setEntityManagerFactory(userMasterEntityManager().getObject());
return transactionManager;
}
}