I'm porting a webservice from .NET WCF, which has a few non-generated classes that help with the control, to a standalone java web service.
I'm having a hard time understanding all the options to connection to an Oracle Database 10g. I've been scanning the internet to try and find a simple way to get a connection or use the default setup provided by Spring Boot.
More or less what I want:
Connection conn = DriverManager.getConnection("connectionDB")
I am using Spring Boot, spring, jpa and tomcat (8.5) connection pooling with Maven. Here is the POM file:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mydomain</groupId>
<artifactId>ArtifactName</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>SolicitacaoProcedimento3_03_02</name>
<description></description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.8.RELEASE</version>
<relativePath/>
<!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web-services</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-rt</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>org.glassfish.metro</groupId>
<artifactId>webservices-rt</artifactId>
<version>2.3</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<scope>test</scope>
<version>2.44.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
<version>4.11</version>
</dependency>
<!-- Spring data JPA, default tomcat pool -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<!-- Oracle JDBC driver -->
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc7</artifactId>
<version>12.1.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.jvnet.jax-ws-commons</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<goals>
<goal>wsimport</goal>
</goals>
<configuration>
<wsdlFiles>
<wsdlFile>tissSolicitacaoProcedimentoV3_03_02.wsdl</wsdlFile>
</wsdlFiles>
<vmArgs>
<vmArg>-Djavax.xml.accessExternalSchema=all</vmArg>
</vmArgs>
<staleFile>${project.build.directory}/jaxws/stale/tissSolicitacaoProcedimentoV3_03_02.stale</staleFile>
</configuration>
<id>wsimport-generate-tissSolicitacaoProcedimentoV3_03_02</id>
<phase>generate-sources</phase>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>javax.xml</groupId>
<artifactId>webservices-api</artifactId>
<version>2.0</version>
</dependency>
</dependencies>
<configuration>
<sourceDestDir>${project.build.directory}/generated-sources/jaxws-wsimport</sourceDestDir>
<xnocompile>true</xnocompile>
<verbose>true</verbose>
<extension>true</extension>
<catalog>${basedir}/src/jax-ws-catalog.xml</catalog>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<webResources>
<resource>
<directory>src</directory>
<targetPath>WEB-INF</targetPath>
<includes>
<include>jax-ws-catalog.xml</include>
<include>wsdl/**</include>
</includes>
</resource>
</webResources>
</configuration>
</plugin>
</plugins>
</build>
Here is my application.properties file:
spring.datasource.url=jdbc:oracle:oci:#tnsDBName
spring.datasource.username=usr
spring.datasource.password=pass
spring.datasource.driver-class-name=oracle.jdbc.OracleDriver
#hibernate config
spring.jpa.database-platform=org.hibernate.dialect.Oracle10gDialect
Any help would be much appreciated.
Can you explain what are you want to achieve? If you need only to setup connection to database (datasource) there is a two ways:
by using application.properties (spring.datasource.*), example
spring.datasource.url= db_url
by writing a Java configuration class
with #Configuration annotation you can read more about it from
here
Related
this post Spring Boot 3 Lombock I already read, it is exactly my issues but the solution does not help me.
The issue occured while migrating from Spring Boot 2.7 to 3.0.1. According to version of lombock both have 1.18.24, which to post above suggests using. See Spring 2.7.X and Spring 3.0.X. (Edit: I got those pages from Spring-Boot-3.0-Migration-Guide)
So I get following error while mvn clean compile on my Entities annotated with #Data
[ERROR] /home/me/code/connect/services/integrator-service/src/main/java/de/comp/integratorservice/service/data/DataService.java:[113,52] cannot find symbol
symbol: method getKey()
location: variable d of type de.comp.integratorservice.rest.dto.DataDto
All pom.xml are altered to hide company names
Here is my modules pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>de.comp</groupId>
<artifactId>pname-services</artifactId>
<version>1.42-SNAPSHOT</version>
</parent>
<artifactId>integrator-service</artifactId>
<packaging>jar</packaging>
<name>integrator-service</name>
<dependencies>
<dependency>
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream-test-support</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>test</scope>
</dependency>
<!-- open-api -->
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-webmvc-core</artifactId>
</dependency>
<!-- when switchting to openapi from springfox swagger the compile didnt work any more... https://mvnrepository.com/artifact/com.google.guava/guava -->
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<!-- Add application packages -->
<!-- some other dependencies from our company -->
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-core</artifactId>
</dependency>
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-sqlserver</artifactId>
</dependency>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
</dependency>
<dependency>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-annotations</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>io.kokuwa.maven</groupId>
<artifactId>helm-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
</plugin>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>dockerfile-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
</plugin>
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Here is the one parent pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>de.comp</groupId>
<artifactId>pname</artifactId>
<version>1.42-SNAPSHOT</version>
</parent>
<artifactId>pname-services</artifactId>
<packaging>pom</packaging>
<properties>
<spring-boot.repackage.skip>true</spring-boot.repackage.skip>
<apt-maven-plugin.version>1.1.3</apt-maven-plugin.version>
<helm-maven-plugin.version>6.6.1</helm-maven-plugin.version>
</properties>
<modules>
...
<module>integrator-service</module>
...
</modules>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>io.kokuwa.maven</groupId>
<artifactId>helm-maven-plugin</artifactId>
<version>${helm-maven-plugin.version}</version>
<configuration>
<chartDirectory>${project.basedir}</chartDirectory>
<chartVersion>${project.version}</chartVersion>
<useLocalHelmBinary>true</useLocalHelmBinary>
</configuration>
<executions>
<execution>
<id>package-helm-chart</id>
<phase>package</phase>
<goals>
<goal>lint</goal>
<goal>package</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.4.0</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/dependencies</outputDirectory>
<includeScope>compile</includeScope>
<includeScope>runtime</includeScope>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
and here is the parent`s parent pom:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>de.comp</groupId>
<artifactId>pname</artifactId>
<version>1.42-SNAPSHOT</version>
<packaging>pom</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.0.1</version>
<relativePath/>
</parent>
<modules>
<module>pname-commons</module>
</modules>
<profiles>
<profile>
<id>default</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<modules>
<module>pname-external-apis</module>
<module>pname-apis</module>
<module>pname-services</module>
<module>pname-tools</module>
<module>pname-tests</module>
</modules>
</profile>
<profile>
<id>pname-tests</id>
<modules>
<module>pname-tests</module>
</modules>
<properties>
<maven.javadoc.skip>true</maven.javadoc.skip>
<maven.test.skip>true</maven.test.skip>
</properties>
</profile>
</profiles>
<properties>
<java.version>17</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<build.tag>latest</build.tag>
<dockerfile.push.skip>true</dockerfile.push.skip>
<codechecks.skip>false</codechecks.skip>
<!-- spring-cloud must fit to the base spring-boot version -->
<spring-cloud.version>2021.0.5</spring-cloud.version>
<org.mapstruct.version>1.5.3.Final</org.mapstruct.version>
<openapi-webmvc.version>1.6.14</openapi-webmvc.version>
<swagger-annotations.version>2.2.7</swagger-annotations.version>
<logstash-logback-encoder.version>7.2</logstash-logback-encoder.version>
<com.microsoft.sqlserver.version>11.2.2.jre17</com.microsoft.sqlserver.version>
<google.guava.version>31.1-jre</google.guava.version>
<checkstyle-maven-plugin.version>3.2.0</checkstyle-maven-plugin.version>
<com.puppycrawl.tools.checkstyle.version>10.5.0</com.puppycrawl.tools.checkstyle.version>
<sca-rules.version>1.3</sca-rules.version>
<spotbugs-maven-plugin.version>4.7.3.0</spotbugs-maven-plugin.version>
<com.github.spotbugs.version>4.7.3</com.github.spotbugs.version>
<de.comp.security-code-generator.version>1.0.8</de.comp.security-code-generator.version>
<de.comp.kcu.version>1.5.0</de.comp.kcu.version>
<org.testcontainers.mssqlserver.version>1.17.6</org.testcontainers.mssqlserver.version>
<com.microsoft.azure.sdk.iot.iot-service-client.versions>1.34.2</com.microsoft.azure.sdk.iot.iot-service-client.versions>
<com.azure.azure-storage-blob.version>12.14.4</com.azure.azure-storage-blob.version>
<net.javacrumbs.shedlock.shedlock-spring.version>4.43.0</net.javacrumbs.shedlock.shedlock-spring.version>
<joda-time.version>2.12.2</joda-time.version>
<querydsl-apt.version>5.0.0</querydsl-apt.version>
<reproducible-build-maven-plugin.version>0.16</reproducible-build-maven-plugin.version>
<exec-maven-plugin.version>3.1.0</exec-maven-plugin.version>
<commons-io.version>2.11.0</commons-io.version>
<apache.collections.version>4.4</apache.collections.version>
<org.immutables.value.version>2.9.3</org.immutables.value.version>
<com.ibm.icu4j.version>72.1</com.ibm.icu4j.version>
<hamcrest-junit.version>2.0.0.0</hamcrest-junit.version>
<esper.version>8.8.0</esper.version>
<esper-runtime.version>8.8.0</esper-runtime.version>
<esper-common.version>8.8.0</esper-common.version>
<esper-compiler.version>8.8.0</esper-compiler.version>
<dockerfile.maven.version>1.4.13</dockerfile.maven.version>
<apache.commons-text.version>1.10.0</apache.commons-text.version>
<mockserver.version>5.14.0</mockserver.version>
<scala.version>2.13.10</scala.version>
</properties>
<distributionManagement>
<repository>
<id>pname</id>
<url>...</url>
</repository>
</distributionManagement>
<repositories>
<repository>
<id>pname</id>
<url>...</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>spring-milestones</id>
<url>https://repo.spring.io/milestone</url>
</repository>
</repositories>
<pluginRepositories>
...
</pluginRepositories>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct</artifactId>
<version>${org.mapstruct.version}</version>
</dependency>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>${org.mapstruct.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
<exclusions>
<!--
Exluding Sping Data mongodb to avoid CVE-2021-44906 (https://avd.aquasec.com/nvd/2021/cve-2021-44906/)
in versions prior to 3.3.5 and 3.4.1
-->
<exclusion>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb</artifactId>
<version>3.4.6</version>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-webmvc-core</artifactId>
<version>${openapi-webmvc.version}</version>
</dependency>
<dependency>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-annotations</artifactId>
<version>${swagger-annotations.version}</version>
</dependency>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>${com.microsoft.sqlserver.version}</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>${google.guava.version}</version>
</dependency>
<dependency>
<groupId>de.comp</groupId>
<artifactId>security-code-generator</artifactId>
<version>${de.comp.security-code-generator.version}</version>
</dependency>
<dependency>
<groupId>de.comp.kcu</groupId>
<artifactId>interfaces</artifactId>
<version>${de.comp.kcu.version}</version>
<exclusions>
<!-- we manage our own version of this dependencies -->
<exclusion>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</exclusion>
<exclusion>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jdk8</artifactId>
</exclusion>
<exclusion>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>mssqlserver</artifactId>
<version>${org.testcontainers.mssqlserver.version}</version>
</dependency>
<dependency>
<groupId>com.microsoft.azure.sdk.iot</groupId>
<artifactId>iot-service-client</artifactId>
<version>${com.microsoft.azure.sdk.iot.iot-service-client.versions}</version>
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-storage-blob</artifactId>
<version>${com.azure.azure-storage-blob.version}</version>
</dependency>
<dependency>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-annotations</artifactId>
<version>${com.github.spotbugs.version}</version>
</dependency>
<dependency>
<groupId>com.ibm.icu</groupId>
<artifactId>icu4j</artifactId>
<version>${com.ibm.icu4j.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
<version>${apache.collections.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-text</artifactId>
<version>${apache.commons-text.version}</version>
</dependency>
<dependency>
<groupId>org.immutables</groupId>
<artifactId>value</artifactId>
<version>${org.immutables.value.version}</version>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-junit</artifactId>
<version>${hamcrest-junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.espertech</groupId>
<artifactId>esper</artifactId>
<version>${esper.version}</version>
</dependency>
<dependency>
<groupId>com.espertech</groupId>
<artifactId>esper-common</artifactId>
<version>${esper-common.version}</version>
</dependency>
<dependency>
<groupId>com.espertech</groupId>
<artifactId>esper-compiler</artifactId>
<version>${esper-compiler.version}</version>
</dependency>
<dependency>
<groupId>com.espertech</groupId>
<artifactId>esper-runtime</artifactId>
<version>${esper-runtime.version}</version>
</dependency>
<dependency>
<groupId>org.mock-server</groupId>
<artifactId>mockserver-core</artifactId>
<version>${mockserver.version}</version>
</dependency>
<dependency>
<groupId>org.mock-server</groupId>
<artifactId>mockserver-client-java</artifactId>
<version>${mockserver.version}</version>
</dependency>
<dependency>
<groupId>net.javacrumbs.shedlock</groupId>
<artifactId>shedlock-spring</artifactId>
<version>${net.javacrumbs.shedlock.shedlock-spring.version}</version>
</dependency>
<dependency>
<groupId>net.javacrumbs.shedlock</groupId>
<artifactId>shedlock-provider-jdbc-template</artifactId>
<version>${net.javacrumbs.shedlock.shedlock-spring.version}</version>
</dependency>
<!-- start
Rise Scala version for "CVE-2022-31692" transient dependency of
spring-cloud-stream-binder-kafka:3.25
-->
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>${scala.version}</version>
</dependency>
<!-- end
Rise Scala version for "CVE-2022-31692" transient dependency of
spring-cloud-stream-binder-kafka:3.25
-->
</dependencies>
</dependencyManagement>
<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>false</addClasspath>
</manifest>
<addMavenDescriptor>false</addMavenDescriptor>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>io.github.zlika</groupId>
<artifactId>reproducible-build-maven-plugin</artifactId>
<version>${reproducible-build-maven-plugin.version}</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>strip-jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>dockerfile-maven-plugin</artifactId>
<version>${dockerfile.maven.version}</version>
<executions>
<execution>
<id>build-tag-latest</id>
<phase>package</phase>
<goals>
<goal>build</goal>
</goals>
</execution>
<execution>
<id>tag-version</id>
<phase>package</phase>
<goals>
<goal>tag</goal>
</goals>
<configuration>
<tag>${build.tag}</tag>
</configuration>
</execution>
<execution>
<phase>package</phase>
<goals>
<goal>push</goal>
</goals>
</execution>
</executions>
<configuration>
...
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>io.github.zlika</groupId>
<artifactId>reproducible-build-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
You have misunderstood something.
Spring CLI
The Spring Boot CLI is a command line tool that you can use to
bootstrap a new project from start.spring.io or encode a password.
CLI is not part of spring-boot-starter. CLI is only a command line tool used as the spring io initialized (Web) but executes from your local command line instead.
So the table that you have referenced in your question means that if you use Spring CLI and ask for lombok dependency in a spring-boot app of either 2.7 or 3.0.1 the initializer will provide you a newly created project where it would already have declared as dependency the lombok 1.18.24.
This would not mean that you don't have to have declared a specific lombok dependency in your spring boot project. spring-boot-starter-parent would not have one declared for you.
It is just that the CLI would make automatically this declaration in the pom of your new project if you choose to use the CLI for project creation.
I am trying to deploy Java Web app developed in spring boot to Azure Devops. pom.xml and Build Pipeline is also running fine but somehow its not pointing to any internal file structure. We have our classes services and controllers at location /src/main/java/com/corrigo but
when adding these in pom.xml its still redirecting to Azures welcome developers page and we have our main starter file at location /src/main/java/com/corrigo/demo/CorrigoModoApplication.java
I think the issue resides in pom.xml. can any one please help me to understand where am I going wrong?
Pom.xml :-
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.4.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>corrigoModo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>corrigoModo</name>
<description>corrigo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
<!-- <src.dir>src/main/java</src.dir> -->
</properties>
<build>
<sourceDirectory>${project.basedir}/src/main/java/com/corrigo</sourceDirectory>
<!--<sourceDirectory>${src.dir}</sourceDirectory> -->
<!-- <profiles>
<profile>
<id>development</id>
<properties>
<src.dir>${project.build.directory}/com/corrigo</src.dir>
</properties>
</profile>
</profiles> -->
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.5</version>
<configuration>
<skipTests>false</skipTests>
<testFailureIgnore>true</testFailureIgnore>
<forkMode>once</forkMode>
</configuration>
</plugin>
<plugin>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-webapp-maven-plugin</artifactId>
<version>1.9.1</version>
<configuration>
<schemaVersion>V2</schemaVersion>
<resourceGroup>***************</resourceGroup>
<appName>********</appName>
<region>********</region>
<pricingTier>**</pricingTier>
<runtime>
<os>linux</os>
<javaVersion>jre8</javaVersion>
<webContainer>jre8</webContainer>
</runtime>
<!-- Begin of App Settings -->
<appSettings>
<property>
<name>corrigoModo</name>
<value>-Dserver.port=80</value>
</property>
</appSettings>
<!-- End of App Settings -->
<deployment>
<resources>
<resource>
<directory>${project.basedir}/target</directory>
<includes>
<include>*.jar</include>
</includes>
</resource>
</resources>
</deployment>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<!-- <version>${maven-surefire-plugin.version}</version> -->
<configuration>
<!-- Force alphabetical order to have a reproducible build -->
<runOrder>alphabetical</runOrder>
<useSystemClassLoader>false</useSystemClassLoader>
</configuration>
</plugin>
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.14.0</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<configuration>
<schemaLanguage>WSDL</schemaLanguage>
<generatePackage>com.medium.article</generatePackage>
<schemaDirectory>src/main/resources/wsdl</schemaDirectory>
<schemaIncludes>
<schemaInclude>*.wsdl</schemaInclude>
</schemaIncludes>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.6.3</version>
</dependency>
<!-- <dependency> <groupId>org.springframework.ws</groupId> <artifactId>spring-ws-security</artifactId>
</dependency> -->
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>3.4.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.googlecode.json-simple/json-simple -->
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>org.springframework.security.oauth</groupId>
<artifactId>spring-security-oauth2</artifactId>
<version>2.2.0.RELEASE</version>
</dependency>
<!-- <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-jwt</artifactId>
</dependency> -->
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>adal4j</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>com.nimbusds</groupId>
<artifactId>oauth2-oidc-sdk</artifactId>
<version>4.5</version>
</dependency>
<!-- <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-config</artifactId>
</dependency> -->
<!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.6</version>
</dependency>
<!-- <dependency> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version> <type>maven-plugin</type> </dependency> -->
<!-- https://mvnrepository.com/artifact/org.json/json -->
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20190722</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.3.6</version>
</dependency>
<dependency>
<groupId>wss4j</groupId>
<artifactId>wss4j</artifactId>
<version>1.5.1</version>
</dependency>
</dependencies>
Build Pipeline is also running fine but somehow its not pointing to any internal file structure.
Since the build/deploy succeed, you should first check if the APP already deploy in Azure.
If there is, you may use the wrong url, so it always redirect to the Azures welcome developers page.
Navigate to the Web App and select the URL from the overview blade. Add /[yourappname] context to the URL. For instance - http://myshuttle1.azurewebsites.net/myshuttledev
More details take a look at this blog-- Deploying a Java-based Tomcat application to Azure
When changed from SpringBoot 2.0.3 to 2.1.6
and from cloud FINCHLEY.Release to Greenwich.SR2 i started getting error when starting spring-boot app in IntelliJ:
java.io.FileNotFoundException:
C:\Users\userName.m2\repository\com\sun\xml\bind\jaxb-core\2.3.0.1\jaxb-api.jar
(The system cannot find the file specified)
java.io.FileNotFoundException:
C:\Users\userName.m2\repository\com\sun\xml\bind\jaxb-impl\2.3.0.1\jaxb-core.jar
(The system cannot find the file specified)
MVCE:
Pom parent (there is only one file on this level of hierarchy):
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>pl.xyz.test</groupId>
<artifactId>test</artifactId>
<version>4.8.0-SNAPSHOT</version>
<packaging>pom</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<spock-core.version>1.0-groovy-2.4</spock-core.version>
<postgresql.version>42.2.5</postgresql.version>
<commons.codec>1.10</commons.codec>
<commons.csv>1.2</commons.csv>
<swagger.version>2.7.0</swagger.version>
<jasperreports.version>6.1.0</jasperreports.version>
<assertj.version>3.0.0</assertj.version>
<freemarker.version>2.3.27-incubating</freemarker.version>
<gmavenplus-plugin.version>1.5</gmavenplus-plugin.version>
<maven-surefire-plugin.version>2.19.1</maven-surefire-plugin.version>
<integration.test.mask>**/*Spec</integration.test.mask>
<integration.test.mask2>**/*Test*</integration.test.mask2>
</properties>
<modules>
<module>test-web</module>
</modules>
<dependencyManagement>
<dependencies>
<dependency>
<!-- Import dependency management from Spring Boot -->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>2.1.6.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-parent</artifactId>
<version>Greenwich.SR2</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
<dependencies>
<!-- implicitly force only junit runner in case of testng dependency found -->
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>${maven-surefire-plugin.version}</version>
</dependency>
</dependencies>
<configuration>
<includes>
<include>${integration.test.mask}</include>
<include>${integration.test.mask2}</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
</project>
Pom of children:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>pl.xyz.test</groupId>
<artifactId>test</artifactId>
<version>4.8.0-SNAPSHOT</version>
</parent>
<artifactId>test-web</artifactId>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-oauth2</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-sleuth</artifactId>
</dependency>
<dependency>
<groupId>org.zalando</groupId>
<artifactId>logbook-spring-boot-starter</artifactId>
<version>1.13.0</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-consul-discovery</artifactId>
</dependency>
</dependencies>
<profiles>
<profile>
<id>default</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.1.6.RELEASE</version>
<configuration>
<executable>true</executable>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
<execution>
<id>build-info</id>
<goals>
<goal>build-info</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
SpringBoot main class:
#SpringBootApplication
#PropertySource(value = {"classpath:test.properties"},
ignoreResourceNotFound = true)
public class TestApp {
public static void main(String[] args) {
SpringApplication.run(TestApp.class, args);
}
}
boostrap.yml
spring:
application:
name: test
server:
max-http-header-size: 65536
If i change im pom parent version to which i described i am not getting these kind of errors.
What should i do to stop getting these errors?
I have 3 projects that looks like this:
The problem is that the common DB code has a converter class, and I am getting the below error while running the Business logic.
Caused by: org.hibernate.AssertionFailure: AttributeConverter class [class com.td.sba.iep.jpa.converters.ModeltoDBAttributeConverter] registered multiple times
What I did:
I tried to exclude the dependencies while packaging the Utility classes using the below code in pom.xml.
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<!-- Fools the plugin into creating the code only jar instead of the runnable one -->
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
<configuration>
<classifier>exec</classifier>
</configuration>
</execution>
</executions>
</plugin>
But when I include the exec jar created into the Business logic, it shows that the utility classes are not found.
WHAT I NEED:
How do I fix the 'org.hibernate.AssertionFailure'?
Should I exclude the dependencies while creating the jar from utility classes? How do I do it?
Incase it matters, I am using Eclipse.
attaching pom.xml: BusinessLogic
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<!-- Use maven profiles to control Spring Boot profile. -->
<profiles>
<profile>
<id>local</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<activeProfile>local</activeProfile>
</properties>
</profile>
<profile>
<id>dev</id>
<properties>
<activeProfile>dev</activeProfile>
</properties>
</profile>
</profiles>
<groupId>com.usermanagement</groupId>
<artifactId>BusinessLogicClass</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Business Logic</name>
<description>Business Logic to handle user requests</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.4.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<org.mapstruct.version>1.2.0.Final</org.mapstruct.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-bean-validators</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>com.fasterxml.uuid</groupId>
<artifactId>java-uuid-generator</artifactId>
<version>3.1.4</version>
</dependency>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-jdk8</artifactId>
<version>1.2.0.Final</version>
</dependency>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jdk8</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>5.0.8.RELEASE</version>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</dependency>
<dependency>
<groupId>org.javers</groupId>
<artifactId>javers-core</artifactId>
<version>3.11.4</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.usermanagement</groupId>
<artifactId>CommonDBLogic</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.usermanagement</groupId>
<artifactId>UtilityClasses</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${java.version}</source> <!-- or higher, depending on your project -->
<target>${java.version}</target> <!-- or higher, depending on your project -->
<annotationProcessorPaths>
<path>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>${org.mapstruct.version}</version>
</path>
</annotationProcessorPaths>
<compilerArgs>
<compilerArg>
-Amapstruct.defaultComponentModel=spring
</compilerArg>
</compilerArgs>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<distributionManagement>
</distributionManagement>
</project>
Utility Class:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.4.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<java.version>1.8</java.version>
</properties>
<groupId>com.usermanagement</groupId>
<artifactId>UtilityClasses</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>UtilityClasses</name>
<description>Utility Classes used by Business Logic class</description>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.objectlab.kit</groupId>
<artifactId>datecalc-common</artifactId>
<version>1.4.0</version>
</dependency>
<dependency>
<groupId>net.objectlab.kit</groupId>
<artifactId>datecalc-jdk8</artifactId>
<version>1.4.0</version>
</dependency>
<dependency>
<groupId>org.javers</groupId>
<artifactId>javers-core</artifactId>
<version>3.11.4</version>
</dependency>
<dependency>
<groupId>com.usermanagement</groupId>
<artifactId>CommonDBLogic</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<!-- Fools the plugin into creating the code only jar instead of the runnable one -->
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
<configuration>
<classifier>exec</classifier>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Common DB Logic:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.usermanagement</groupId>
<artifactId>CommonDBLogic</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>CommonDBLogic</name>
<description>Common DB Logic used by Business class</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.4.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
<version>2.0.3.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
<version>2.0.3.RELEASE</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-envers</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<version>2.0.2.RELEASE</version>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>19.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<!-- Fools the plugin into creating the code only jar instead of the runnable one -->
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
<configuration>
<classifier>exec</classifier>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<distributionManagement>
</distributionManagement>
</project>
Have you tried to use <exclusions> element on this project dependencies? Like:
Business Logic Project pom.xml file:
<dependency>
<groupId>com.utility.project</groupId>
<artifactId>UtilityProject</artifactId>
<version>1.0.0</version>
<exclusions>
<exclusion>
<groupId>group.id.jar.you.want.to.exclude</groupId>
<artifactId>artifact.id.jar.you.want.to.exclude</artifactId>
</exclusion>
</exclusions>
</dependency>
UPDATE
Since you already have CommonDB dependencies on your UtilityProject pom, remove this CommonDB dependency from your business logic pom. This error is because you have 2 classes (same class) being registered with same name. If you already have CommonDB dependency on UtilityProject and you use this UtilityProject as dependency on Business, you don't need to import it twice.
I have EAR application written with EJB 3.1, where I'm using JPA 2.0.
Persistance unit is configured to use JTA
<persistence-unit name="JPACommonParameters" transaction-type="JTA">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
I've created simple deployment, where in EJB I inject Entity manager just like this
#PersistenceContext(unitName = "JPACommonParameters")
protected EntityManager em;
Using this jpa I called simple query using createNamedQuery.
Application is deployed on WLS 12.1.1.0, managed server.
After first deployment it is working. Everything is fine.
After updating the same application without any change I've receiving ClastCastException as object returned from query is not the same as in application.
result = (ParamDef) em.createNamedQuery("ParamDef.findActiveParamDef").
getSingleResult();
After long investigation I've found, that problem is with classloader. Object returned from entity manager is loaded by different classloader(Classloader used during first deployment) than object ParamDef in bracket I'm casting.
Everything is working fine when I will restart manged wls server.
My question is: How to configure application of wls to initialize entityManger every redeploy of application on server to get it working without restart.
Here is my pom file
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<artifactId>ofs-direct-services</artifactId>
<groupId>com.oproc.first.app</groupId>
<version>1.1</version>
</parent>
<artifactId>IT-app</artifactId>
<modelVersion>4.0.0</modelVersion>
<packaging>war</packaging>
<name>IT-app Integ. Tests for app</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<cxf.version>2.2.3</cxf.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jboss.arquillian</groupId>
<artifactId>arquillian-bom</artifactId>
<version>1.1.1.Final</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jboss.spec</groupId>
<artifactId>jboss-javaee-6.0</artifactId>
<version>1.0.0.Final</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-container</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.container</groupId>
<artifactId>arquillian-wls-remote-12.1</artifactId>
<version>1.0.0.Alpha2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.weld</groupId>
<artifactId>weld-core</artifactId>
<version>1.1.5.Final</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.oproc.first.app</groupId>
<artifactId>customer-app-services</artifactId>
<version>1.1</version>
<type>ejb</type>
</dependency>
<dependency>
<groupId>com.oproc.first.common.parameters</groupId>
<artifactId>common-parameters-services</artifactId>
<version>1.0</version>
<type>ejb</type>
</dependency>
<dependency>
<groupId>com.oproc.first.common.parameters</groupId>
<artifactId>common-parameters-api</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>com.oproc.first.common.parameters</groupId>
<artifactId>common-parameters-db</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>com.oproc.first.common.parameters</groupId>
<artifactId>common-parameters-services</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>com.oproc.first</groupId>
<artifactId>ejb-tuxedo-connector-ejb</artifactId>
<version>1.0</version>
<type>ejb</type>
</dependency>
<dependency>
<groupId>com.oproc.first</groupId>
<artifactId>ejb-tuxedo-connector-client</artifactId>
<version>1.0</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>com.oproc.first</groupId>
<artifactId>db4b-db</artifactId>
<version>1.0</version>
<type>jar</type>
</dependency>
</dependencies>
<profiles>
<profile>
<id>no_integration_testing</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12</version>
<executions>
<execution>
<id>default-test</id>
<configuration>
<excludes>
<exclude>**/*Test.java</exclude>
</excludes>
<skipTests>true</skipTests>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>integration_testing</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<compilerArguments>
<endorseddirs>${project.build.directory}/endorsed</endorseddirs>
</compilerArguments>
</configuration>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12</version>
<executions>
<execution>
<id>surefire-it</id>
<phase>integration-test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<skipTests>false</skipTests>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>