Clean up jpa setting.

This commit is contained in:
Paulo Gustavo Veiga 2024-02-03 19:37:10 -08:00
parent f86f96a35e
commit 7724d9106d
5 changed files with 44 additions and 75 deletions

View File

@ -131,11 +131,6 @@
<artifactId>mysql-connector-j</artifactId> <artifactId>mysql-connector-j</artifactId>
<version>8.1.0</version> <version>8.1.0</version>
</dependency> </dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-dbcp2</artifactId>
<version>2.9.0</version>
</dependency>
<dependency> <dependency>
<groupId>org.eclipse.angus</groupId> <groupId>org.eclipse.angus</groupId>
<artifactId>jakarta.mail</artifactId> <artifactId>jakarta.mail</artifactId>
@ -153,6 +148,13 @@
<version>1.7</version> <version>1.7</version>
</dependency> </dependency>
<!-- Connection Pool-->
<dependency>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
<version>5.1.0</version>
</dependency>
<!-- Only for test purposes --> <!-- Only for test purposes -->
<dependency> <dependency>
<groupId>org.hsqldb</groupId> <groupId>org.hsqldb</groupId>

View File

@ -10,7 +10,7 @@ import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.ImportResource; import org.springframework.context.annotation.ImportResource;
@ComponentScan(basePackageClasses = {AuthenticationProvider.class, MindmapServiceImpl.class, LabelManagerImpl.class, VelocityEngineUtils.class}) @ComponentScan(basePackageClasses = {AuthenticationProvider.class, MindmapServiceImpl.class, LabelManagerImpl.class, VelocityEngineUtils.class})
@Import({HibernateConfig.class, SecurityConfig.class}) @Import({JPAConfig.class, SecurityConfig.class})
@EnableAutoConfiguration @EnableAutoConfiguration
@ImportResource(value = {"classpath:spring/wisemapping-mail.xml"}) @ImportResource(value = {"classpath:spring/wisemapping-mail.xml"})
public class CommonConfig { public class CommonConfig {

View File

@ -1,53 +0,0 @@
package com.wisemapping.config.common;
import com.wisemapping.dao.MindmapManagerImpl;
import com.wisemapping.model.User;
import com.wisemapping.service.MindmapServiceImpl;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
@Configuration
@EnableJpaRepositories(basePackageClasses={MindmapServiceImpl.class, MindmapManagerImpl.class})
@EntityScan(basePackageClasses= User.class)
public class HibernateConfig {
// @Bean
// public HibernateTransactionManager hibernateTransactionManager() {
// final HibernateTransactionManager result = new HibernateTransactionManager();
// result.setNestedTransactionAllowed(true);
// // @Todo: Am I creatting two instances ???
// result.setSessionFactory(sessionFactory().getObject());
// return result;
// }
//
// private Properties hibernateProperties() {
// final Properties result = new Properties();
// result.setProperty("hibernate.dialect", dbDialect);
// result.setProperty("hibernate.default_batch_fetch_size", "200");
// result.setProperty("hibernate.nestedTransactionAllowed", "true");
// result.setProperty("hibernate.auto_quote_keyword", "true");
//
// return result;
// }
//
// @Bean
// public DataSource dataSource() {
// final BasicDataSource result = new BasicDataSource();
// result.setDriverClassName(dbDriver);
// result.setUrl(dbUrl);
// result.setUsername(dbUsername);
// result.setPassword(dbPassword);
// result.setTestOnBorrow(dbSetOnBorrow);
//
// result.setDefaultQueryTimeout(15);
// result.setMaxTotal(100);
// result.setMaxIdle(30);
// result.setInitialSize(5);
// result.setMaxWaitMillis(10000);
// result.setValidationQuery(dbValQuery);
//
// return result;
// }
}

View File

@ -0,0 +1,16 @@
package com.wisemapping.config.common;
import com.wisemapping.dao.MindmapManagerImpl;
import com.wisemapping.model.User;
import com.wisemapping.service.MindmapServiceImpl;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
@Configuration
@EnableJpaRepositories(basePackageClasses={MindmapServiceImpl.class, MindmapManagerImpl.class})
@EntityScan(basePackageClasses= User.class)
public class JPAConfig {
}

View File

@ -1,5 +1,5 @@
################################################################################## ##################################################################################
SpringBoot Common SpringBoot DataSource
################################################################################## ##################################################################################
# JPA # JPA
@ -11,9 +11,22 @@ spring.jpa.properties.hibernate.format_sql=true
spring.sql.init.mode=always spring.sql.init.mode=always
spring.sql.init.platform=hsqldb spring.sql.init.platform=hsqldb
# LOG spring.jpa.properties.hibernate.default_batch_fetch_size=200
logging.level.root=INFO #spring.jpa.properties.hibernate.auto_quote_keyword=true
logging.level.org.apache.tomcat=INFO
# Connection pool (https://docs.spring.io/spring-boot/docs/current/reference/html/application-properties.html#application-properties.data.spring.datasource.hikari)
#spring.datasource.hikari.connection-test-query=
#spring.datasource.hikari.connection-timeout=
# Embed Datasource Configuration
database.base.url=/Users/veigap/
spring.datasource.url=jdbc:hsqldb:file:${database.base.url}/db/wisemapping
spring.datasource.username=sa
spring.datasource.password=
spring.datasource.driver-class-name = org.hsqldb.jdbc.JDBCDriver
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.HSQLDialect
################################################################################## ##################################################################################
# Mail configuration. Must be configured to enable user registration confirmation. # Mail configuration. Must be configured to enable user registration confirmation.
@ -119,15 +132,6 @@ security.oauth2.google.url=https//review
#accounts.exclusion.domain= #accounts.exclusion.domain=
################################################################################## # LOG
# Database Configuration logging.level.root=INFO
################################################################################## logging.level.org.apache.tomcat=INFO
database.base.url=/Users/veigap/
spring.datasource.url=jdbc:hsqldb:file:${database.base.url}/db/wisemapping
spring.datasource.username=sa
spring.datasource.password=
spring.datasource.driver-class-name = org.hsqldb.jdbc.JDBCDriver
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.HSQLDialect