updated db configurations

This commit is contained in:
Michele Artini 2022-12-13 08:51:08 +01:00
parent ee323bca6d
commit 55113b3c60
5 changed files with 38 additions and 46 deletions

View File

@ -1,18 +0,0 @@
[INFO] Scanning for projects...
[INFO]
[INFO] -----------------< eu.dnetlib.dhp:dnet-is-application >-----------------
[INFO] Building dnet-is-application 3.2.9-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.390 s
[INFO] Finished at: 2022-06-27T07:49:25+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Unknown lifecycle phase "dependency". You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/LifecyclePhaseNotFoundException

View File

@ -11,6 +11,7 @@ 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.jdbc.core.JdbcTemplate;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.transaction.PlatformTransactionManager;
@ -18,37 +19,41 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
@Configuration
@EnableTransactionManagement
@EnableJpaRepositories(entityManagerFactoryRef = "entityManagerFactory", basePackages = {
"eu.dnetlib.data.is.context.repository",
"eu.dnetlib.data.is.resource.repository",
"eu.dnetlib.data.is.vocabulary.repository",
"eu.dnetlib.data.is.wf.repository"
@EnableJpaRepositories(entityManagerFactoryRef = "mainEntityManagerFactory", transactionManagerRef = "mainTransactionManager", basePackages = {
"eu.dnetlib.data.is"
})
public class MainDBConfig {
@Primary
@Bean(name = "dataSource")
@ConfigurationProperties(prefix = "spring.datasource")
@Bean(name = "mainDataSource")
@ConfigurationProperties(prefix = "is.datasource")
public DataSource dataSource() {
return DataSourceBuilder.create().build();
}
@Primary
@Bean(name = "entityManagerFactory")
@Bean(name = "mainEntityManagerFactory")
public LocalContainerEntityManagerFactoryBean entityManagerFactory(
final EntityManagerFactoryBuilder builder,
@Qualifier("dataSource") final DataSource dataSource) {
@Qualifier("mainDataSource") final DataSource ds) {
return builder
.dataSource(dataSource)
.packages("eu.dnetlib.data.is.context.model", "eu.dnetlib.data.is.resource.model", "eu.dnetlib.data.is.vocabulary.model", "eu.dnetlib.data.is.wf.model")
.dataSource(ds)
.packages("eu.dnetlib.data.is")
.persistenceUnit("is")
.build();
}
@Primary
@Bean(name = "transactionManager")
@Bean(name = "mainTransactionManager")
public PlatformTransactionManager transactionManager(
@Qualifier("entityManagerFactory") final EntityManagerFactory entityManagerFactory) {
return new JpaTransactionManager(entityManagerFactory);
@Qualifier("mainEntityManagerFactory") final EntityManagerFactory emf) {
return new JpaTransactionManager(emf);
}
@Primary
@Bean(name = "mainJdbcTemplate")
public JdbcTemplate jdbcTemplate1(@Qualifier("mainDataSource") final DataSource ds) {
return new JdbcTemplate(ds);
}
}

View File

@ -10,6 +10,7 @@ import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.transaction.PlatformTransactionManager;
@ -18,7 +19,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
@Configuration
@EnableTransactionManagement
@EnableJpaRepositories(entityManagerFactoryRef = "openaireEntityManagerFactory", transactionManagerRef = "openaireTransactionManager", basePackages = {
"eu.dnetlib.data.openaire.dsm.repository"
"eu.dnetlib.data.openaire"
})
public class OpenaireDBConfig {
@ -31,17 +32,22 @@ public class OpenaireDBConfig {
@Bean(name = "openaireEntityManagerFactory")
public LocalContainerEntityManagerFactoryBean openaireEntityManagerFactory(
final EntityManagerFactoryBuilder builder,
@Qualifier("openaireDataSource") final DataSource dataSource) {
@Qualifier("openaireDataSource") final DataSource ds) {
return builder
.dataSource(dataSource)
.packages("eu.dnetlib.data.openaire.dsm.model")
.dataSource(ds)
.packages("eu.dnetlib.data.openaire")
.persistenceUnit("openaire")
.build();
}
@Bean(name = "openaireTransactionManager")
public PlatformTransactionManager opeanaireTransactionManager(
@Qualifier("openaireEntityManagerFactory") final EntityManagerFactory openaireEntityManagerFactory) {
return new JpaTransactionManager(openaireEntityManagerFactory);
@Qualifier("openaireEntityManagerFactory") final EntityManagerFactory emf) {
return new JpaTransactionManager(emf);
}
@Bean(name = "openaireJdbcTemplate")
public JdbcTemplate jdbcTemplate1(@Qualifier("openaireDataSource") final DataSource ds) {
return new JdbcTemplate(ds);
}
}

View File

@ -23,6 +23,7 @@ import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
@ -61,9 +62,6 @@ import eu.dnetlib.openaire.dsm.utils.DsmMappingUtils;
import eu.dnetlib.openaire.dsm.utils.ResponseUtils;
import eu.dnetlib.openaire.dsm.utils.VocabularyClient;
/**
* Created by claudio on 20/10/2016.
*/
@Service
@ConditionalOnProperty(value = "openaire.api.enable.dsm", havingValue = "true")
public class DsmService {
@ -89,6 +87,7 @@ public class DsmService {
private VocabularyClient vocabularyClient;
@Autowired
@Qualifier("openaireJdbcTemplate")
private JdbcTemplate jdbcTemplate;
public List<Country> listCountries() throws DsmException {

View File

@ -15,10 +15,10 @@ management.endpoints.web.path-mapping.prometheus = metrics
management.endpoints.web.path-mapping.health = health
# Main Database for IS
spring.datasource.jdbc-url=jdbc:postgresql://localhost:5432/new_is
spring.datasource.username=dnet
spring.datasource.password=dnetPwd
spring.datasource.driver-class-name=org.postgresql.Driver
is.datasource.jdbc-url=jdbc:postgresql://localhost:5432/new_is
is.datasource.username=dnet
is.datasource.password=dnetPwd
is.datasource.driver-class-name=org.postgresql.Driver
# Database for Main Entities
openaire.datasource.jdbc-url=jdbc:postgresql://localhost:5432/dnet_openaireplus
@ -27,7 +27,6 @@ openaire.datasource.password=dnetPwd
openaire.datasource.driver-class-name=org.postgresql.Driver
# Hibernate ddl auto (create, create-drop, validate, update)
spring.jpa.database=default
spring.jpa.hibernate.ddl-auto = validate
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.PostgreSQLDialect
spring.jpa.properties.hibernate.hbm2dll.extra_physical_table_types = MATERIALIZED VIEW
@ -36,6 +35,7 @@ spring.jpa.open-in-view=true
spring.jpa.properties.hibernate.show_sql=false
spring.jpa.properties.hibernate.use_sql_comments=false
spring.jpa.properties.hibernate.format_sql=false
spring.jpa.database=default
openaire.api.enable.dsm = true