java liquibase maven plugin safe store password - java

Im using liquibase in a standard java project (non spring) and using maven to manage my migrations and rollbacks
to the plugin configuration in maven im passing a liquibase.properties file that currently has a plain password in it
here is the relevant code
<plugin>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<version>4.3.3</version>
<configuration>
<propertyFile>src/main/resources/liquibase.properties</propertyFile>
</configuration>
<executions>
<execution>
<phase>process-resources</phase>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.liquibase.ext</groupId>
<artifactId>liquibase-postgresql</artifactId>
<version>4.3.3</version>
</dependency>
</dependencies>
</plugin>
and the properties file
driver=org.postgresql.Driver
url=jdbc:postgresql://localhost:5432/testdb
username=test
password=test
changeLogFile=src/main/resources/db/changelog-master.xml
how can i avoid this

You may use your own property provider class to handle encryption. I don't see any docs for this but you can browse the commits on this link, it might help.
Also the answer on this post will help you with using propertyProviderClass in liquibase.
Other than this, you can go through this article to have an idea.

Related

What is the usage of JSP compiler?

Recently I started working on a maven based Struts project using JSP and Java 7.
I see the dependency in pom as following.
<plugin>
<groupId>org.jasig.mojo.jspc</groupId>
<artifactId>jspc-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
<configuration>
<sources>
<directory>${basedir}/src/main/webapp/</directory>
<includes>
<include>**/*.jsp</include>
</includes>
</sources>
<includeInProject>false</includeInProject>
<validateXml>false</validateXml>
</configuration>
<dependencies>
<dependency>
<groupId>org.jasig.mojo.jspc</groupId>
<artifactId>jspc-compiler-tomcat8</artifactId>
<version>2.0.2</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
<version>1.5.3</version>
</dependency>
</dependencies>
</plugin>
I removed it and build project successfully. The UI of application works fine.
Can someone please help me in understanding the usage of this plugin?
JSP pre-compilers avoid a JSP compilation delay when a JSP page is first hit.
It is an optimization that may or may not be actually worth it, but for high-page-count high-usage sites that use server-side HTML generation it may be worth it.
For example, see https://www.mulesoft.com/tcat/tomcat-jsp
Meta
Questions like this can be self-answered by searching the web. The first step is to identify what you're looking at, which it appears you did, since you identified the dependency as a JSP compiler.
Once you know what you're trying to look for, ask the web "why use a JSP compiler" or something similar. The reference I posted above was one of the early results when I searched for this.

Is there a way to checkout git repository, to certain folder with maven?

I am attempting to automatize download of repository containing only protocol-buffers (with structure), to "resource" folder for later processing.
I need this kind of functionality, to keep my *.proto files separated from c++ and java code, as they are technically not connected with each other (java application is used for debugging).
My desired effect is to at least checkout repo into project —
My dreamed effect is to get this repo updated every time I run maven.
BR
EDIT
After working a lot with such a problem, I found personally that the git submodule might be a solution for you (if you are not using svn).
Okay, so after googling, I have came across this: maven-scm-plugin, which even from description solves my request.
To save time for most people I will paste example of usage, to make it work.
You need to add this to your pom structure:
<project>
<scm>
<connection>scm:git:[YOUR_PROJECT_URL]</connection>
</scm>
<--! second part -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-scm-plugin</artifactId>
<dependencies>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
<version>2.1</version>
</dependency>
<dependency>
<groupId>org.apache.maven.scm</groupId>
<artifactId>maven-scm-provider-gitexe</artifactId>
<version>1.2</version>
</dependency>
</dependencies>
<version>1.0</version>
<configuration>
<connectionType>connection</connectionType>
<!-- YOUR PATH HERE -->
<checkoutDirectory>src/main/resources/meta</checkoutDirectory>
</configuration>
<executions>
<execution>
<id>tag</id>
<phase>deploy</phase>
<goals>
<goal>tag</goal>
</goals>
</execution>
</executions>
</plugin>
</project>

Produce tree output with Surefire like the JUnit 5 console launcher

The Console Launcher that comes with JUnit Platform (from JUnit 5) produces a quite nice summary view at the end. The Maven Surefire plugin, however, has a very simple output.
Is it possible to create with Surefire output similar to what the launches creates?
My current workaround is to disable surefire and use exec-maven-plugin to manually run ConsoleLauncher:
<!-- disable surefire -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version><!-- ... --></version>
<executions>
<execution>
<id>default-test</id>
<phase>none</phase>
</execution>
</executions>
</plugin>
<!-- enable ConsoleLauncher -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version><!-- ... --></version>
<executions>
<execution>
<phase>test</phase>
<goals><goal>java</goal></goals>
<configuration>
<mainClass>org.junit.platform.console.ConsoleLauncher</mainClass>
<arguments>
<argument>--scan-class-path</argument>
<argument>${project.build.directory}/test-classes</argument>
</arguments>
<classpathScope>test</classpathScope>
</configuration>
</execution>
</executions>
</plugin>
<!-- ... -->
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-console-standalone</artifactId>
<version><!-- ... --></version>
<scope>test</scope>
</dependency>
I know it's an old topic, but this topic was the reason I've developed this extension 2 years ago: https://github.com/fabriciorby/maven-surefire-junit5-tree-reporter
Basically, to get your tree output, add this to your pom.xml:
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M7</version>
<dependencies>
<dependency>
<groupId>me.fabriciorby</groupId>
<artifactId>maven-surefire-junit5-tree-reporter</artifactId>
<version>1.0.1</version>
</dependency>
</dependencies>
<configuration>
<reportFormat>plain</reportFormat>
<consoleOutputReporter>
<disable>true</disable>
</consoleOutputReporter>
<statelessTestsetInfoReporter
implementation="org.apache.maven.plugin.surefire.extensions.junit5.JUnit5StatelessTestsetInfoTreeReporterUnicode">
</statelessTestsetInfoReporter>
</configuration>
</plugin>
And the magic happens
Currently Surefire is developig extensions 1 for embedded Surefire features, and a standalone extension supporting JUnit5 DisplayName.
One of these extensions is a console logger of testset information. Very similar output to the console in 2 might be possible to support as well then.
The extensions is a set of Java abstractions and Surefire/Failsafe plugins will contain default implementations of these abstractions. The other progressive extension implementations, with the output like in 2, would kindly require users to support Surefire project to implement the extensions in their own GitHub repositories (not in ASF). Surefire is welcome to list all third party implementations of these extensions on the ASF Maven Surefire webpage.
This way (Open-Closed DP) we believe we would provide you with certain freedom to change the behavior of plugins without reporting real Jira issues and without waiting for a new feature release.
Sure.
Feel free to open a feature request to extend the current summary output at https://issues.apache.org/jira/projects/SUREFIRE/issue and perhaps a Pull Request against https://github.com/apache/maven-surefire ;-)

Execution default of goal de.juplo:hibernate4-maven-plugin:1.1.0:export failed

I am trying to execute hibernate4-maven-plugin with Oracle using the folowing configuration in my pom.xml :
<plugin>
<groupId>de.juplo</groupId>
<artifactId>hibernate4-maven-plugin</artifactId>
<version>1.1.0</version>
<executions>
<execution>
<phase>process-test-resources</phase>
<goals>
<goal>export</goal>
</goals>
</execution>
</executions>
<configuration>
<outputFile>${project.build.directory}/test-classes/schema.sql</outputFile>
<format>true</format>
<force>true</force>
<delimiter>;</delimiter>
<type>CREATE</type>
<target>SCRIPT</target>
<driverClassName>oracle.jdbc.driver.OracleDriver</driverClassName>
<hibernateDialect>org.hibernate.dialect.Oracle10gDialect
</hibernateDialect>
</configuration>
<!-- not working
<dependencies>
<dependency>
<groupId>org.xerial.thirdparty</groupId>
<artifactId>jdbc-api</artifactId>
<version>1.4</version>
</dependency>
</dependencies>
-->
</plugin>
but Eclipse shows the following error, saying java.sql.Date is missing :
Execution default of goal de.juplo:hibernate4-maven-plugin:1.1.0:export failed:
A required class was missing while executing
de.juplo:hibernate4-maven-plugin:1.1.0:export: java/sql/Date
I wonder why this is a problem as java.sql.Date is included in the JDK (rt.jar)
I tried to add the dependency to a jar containing java.sql.Date (org.xerial.thirdparty.jdbc-api) but without success.
Thank you for your help.
I just updated my IDE to Spring Tools Suite 3.9.2.RELEASE, migrate the workspace and the error has gone :)

How to solve an issue Eclipse not showing Javadocs for javax.annotation package in webapp-javaee7 archetype Maven project?

I am using Eclipse Oxygen, but this was also the issue in the Neon version. I have started new Maven Project and selected webapp-javaee7 archetype. After the creation of the project is done, pom.xml was configured like this:
<properties>
<endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<compilerArguments>
<endorseddirs>${endorsed.dir}</endorseddirs>
</compilerArguments>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<outputDirectory>${endorsed.dir}</outputDirectory>
<silent>true</silent>
<artifactItems>
<artifactItem>
<groupId>javax</groupId>
<artifactId>javaee-endorsed-api</artifactId>
<version>7.0</version>
<type>jar</type>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
So, the javaee-endorsed-api-7.0.jar is added to the Endorsed libraries. As I understood from this post that jar file contains Annotations package javax.annotation.
I have imported package javax.annotation to some of my classes inside this project, and used some annotations. When I hover over some of these annotations I get the message: Note: This element neither has attached source nor attached Javadoc and hence no Javadoc could be found.
When I try to open "attached" Javadoc in the browser I get warning dialog stating: The documentation location for (annotation name) has not been configured. For elements from libraries specify the Javadoc location URL on properties page of the parent JAR ...\target\endorsed\javaee-endorsed-api-7.0.jar.
It is not possible to attach source code or Javadoc to javaee-endorsed-api-7.0.jar.
When I make plain Java project and use javax.annotation package Javadocs are shown as expected.
How to solve this and make Eclipse show Javadocs for javax.annotation package within this Maven project I am working on?
Thanks.
I have found the solution for this issue among comments on this post. The solution is on project basis:
select particular project
go to Project -> Properties -> Java Build Path -> Order and Export
reorder libraries until the javadocs appear.
For me it worked to place JRE System Library on top of Endorsed Libraries. Which means that Eclipse is pulling javadocs from libraries in order specified by this tab. And because all javadocs for annotations in question are defined in javadocs placed in proper directory of jdk installation (on this tab annotated as JRE System Library) now they are shown as expected inside Eclipse.
it may be dependency issue or may be JDK and JRE version, i you can try this on JDK 8 and use 6.0 version of javaee-web-api. you can also refer the answer into stackoverflow link here.
Your solution didn't work for me ( maybe I just didn't reorder them enough times? ) but in case somebody else comes across the same problem, this worked straight away for me:
I removed all the libraries ( Project, libraries ), cleaned the project so that all the missing dependencies would show as error, then added them and cleaned the profile again. Maybe this can help somebody
Maven will not download source for dependencies that are not explicitly decleared in your pom.xml. I was using spring boot,so i did not have to include that java.persistence, as spring boot will include it without mention. What i did to fix it was to explicitly specify java.persistence in pom.xml like this
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>javax.persistence-api</artifactId>
<!-- <version>2.2</version> -->
</dependency>
Note: I comented out the version because Spring boot will choose the best version for me.

Categories

Resources