How to build a quick Lucene Search

Helo – today I wanted to post a small tutorial for a small index and search operation using the Lucene indexer and Maven for the project setup. Setup Create an empty Maven sample project using the Eclipse Maven Plugin or use the following console command: mvn archetype:create -DgroupId=com.hascode.demo.search -DartifactId=lucene-sample Here is my pom.xml there are some dependencies for Lucene defined: <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"> <modelVersion>4.0.0</modelVersion> <groupId>com.hascode.demo.search</groupId> <artifactId>lucene-sample</artifactId> <version>0.0.1-SNAPSHOT</version> <name>My Lucene Search Sample</name> <description>Lucene Search Sample</description> <dependencies> <dependency> <groupId>org.apache.lucene</groupId> <artifactId>lucene-core</artifactId> <version>2.4.1</version> </dependency> <dependency> <groupId>lucene</groupId> <artifactId>lucene</artifactId> <version>1.4.3</version> </dependency> </dependencies> </project> ...

March 25, 2010 · 3 min · 540 words · Micha Kops

How to add a local lib directory to Maven

Sometimes there is a dependency not available at a remote repository and one is too lazy to set up a local maven repository – that’s when one adds a directory in the project structure and wants maven to find dependencies there. Create a directory called “lib” in the project root Add the following markup to the pom.xml inside the <repositories>-Tag (create if it does not exist): <repository> <id>lib</id> <name>lib</name> <releases> <enabled>true</enabled> <checksumPolicy>ignore</checksumPolicy> </releases> <snapshots> <enabled>false</enabled> </snapshots> <url>file://${project.basedir}/lib</url> </repository> ...

March 18, 2010 · 1 min · 206 words · Micha Kops

Atlassian Snippets

Disable YUI compressor <plugin> <groupId>com.atlassian.maven.plugins</groupId> <artifactId>maven-jira-plugin</artifactId> <version>${amps.version}</version> <extensions>true</extensions> <configuration> <compressResources>false</compressResources> [..] </configuration> </plugin> Confluence – Get favourites by user Using the label manager. List getFavouriteSpaces(String username) Confluence – Determine the base URL Using the SettingsManager: String baseUrl = settingsManager.getGlobalSettings().getBaseUrl(); Confluence – Get the context path Using the BootstrapManager: String contextPath = bootstrapManager.getWebAppContextPath(); Confluence – Using Velocity Template for a Macro final VelocityContext contextMap = new VelocityContext(MacroUtils.defaultVelocityContext()); contextMap.put("key", obj); // references obj as variable named $key in the velocity template VelocityUtils.getRenderedTemplate("path/to/template.vm", contextMap); ...

March 1, 2010 · 3 min · 544 words · Micha Kops

Java Snippets

Remote Debug a Pod’s Java Process Simple steps for remote debugging a Java process running on a k8 pod: Edit deployment and add the following parameters to the Java start line: -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=127.0.0.1:5005 Also add the following port mapping at the section container → ports in the deployment: - containerPort: 5005 protocol: TCP Safe, wait for the new pods and then add a port forward for port 5005 for this pod: kubectl port-forward podname 5005 ...

March 1, 2010 · 13 min · 2583 words · Micha Kops

Maven Snippets

Extract Coordinates from the POM Helpful for build and integration environments, pipelines etc. Exctract the Project version from the pom.xml mvn org.apache.maven.plugins:maven-help-plugin:3.1.0:evaluate -Dexpression=project.version -q -DforceStdout Override a Property via local configuration e.g. to override the property xxx from your project’s pom.xml Create a directory .mvn in your project directory root Create a file named maven.config in this directory Insert -Dxxx=newvalue into the file to override this property Don’t forget to add .mvn to your .gitignore! ...

March 1, 2010 · 2 min · 401 words · Micha Kops

Spring Boot Snippets

Define and Configure Log Groups This allows to configure a group of loggers at the same time Define a log group named myaspect with two packages application.properties logging.group.myaspect=com.hascode.package1,com.hascode.package2 Configure the log group and set all loggers to level TRACE application.properties logging.level.myaspect=TRACE This is also possible as parameter on startup java -Dlogging.level.myaspect=TRACE myapp.jar Use JUnit 5 with Spring Boot Use newer versions of Surefire and Failsafe plugins: <properties> [..] <maven-failsafe-plugin.version>2.22.0</maven-failsafe-plugin.version> <maven-surefire-plugin.version>2.22.0</maven-surefire-plugin.version> </properties> ...

March 1, 2010 · 6 min · 1082 words · Micha Kops