kundera icon indicating copy to clipboard operation
kundera copied to clipboard

would you consider to add a tutorial with kundera and spring boot ?

Open bedinsky opened this issue 7 years ago • 2 comments

this tutorial on kundera spring does not help with spring boot https://github.com/Impetus/Kundera/wiki/Building-Applications-with-Kundera-and-Spring

I'm trying to start a spring boot application with jpa using kundera but I do not find out what to write in "Application Properties File"

Eventually I have disable datasource auto configuration and instantiated a EntityManagerFactoryBean

		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-data-jpa</artifactId>
		</dependency>

bedinsky avatar May 08 '18 16:05 bedinsky

Hi @bedinsky,

We will plan to add a tutorial on this soon. Meanwhile, we appreciate if any community member wants to contribute to this.

As of now, you can keep applicationContext.xml file and use

@ImportResource("classpath:applicationContext.xml") in your SpringBootApplication class.

devender-yadav avatar May 11 '18 12:05 devender-yadav

Hi, thank you for answering ! I do not use applicationContex.xml Here is my example if someone prefers programmatic configuration. persistence.xml is mandatory in classpath

@EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class})
@SpringBootApplication
public class Application 
{
	public static void main(String[] args) {
	      new SpringApplicationBuilder(Application.class)
	      .sources(PersistenceJPAConfig.class)
          .logStartupInfo(true)
          .build()
          .run(args);		
	}
}

@Configuration
@EnableTransactionManagement(order=10)
@ComponentScan({ "yourpackage.persistence" })
public class PersistenceJPAConfig {

	public PersistenceJPAConfig() {
		super();
	}

	@PostConstruct
	public void init() {
	}


	
	@Bean
	public LocalContainerEntityManagerFactoryBean entityManagerFactoryBean() {
		final LocalContainerEntityManagerFactoryBean factoryBean = new LocalContainerEntityManagerFactoryBean();
		factoryBean.setPersistenceUnitName("cassandra_pu");
		return factoryBean;
	}

	@Bean
	public PlatformTransactionManager transactionManager(
			final EntityManagerFactory emf) {
		final JpaTransactionManager transactionManager = new JpaTransactionManager();
		transactionManager.setEntityManagerFactory(emf);
		return transactionManager;
	}	
}

bedinsky avatar May 11 '18 13:05 bedinsky