Skip to content

daggerok/cdi-example

Repository files navigation

cdi-example Build Status

Maven java main CDI example

  • add proper dependencies

    <dependency>
      <groupId>org.jboss.weld.se</groupId>
      <artifactId>weld-se-core</artifactId>
      <version>3.0.5.Final</version>
    </dependency>
    <dependency>
      <groupId>javax.enterprise</groupId>
      <artifactId>cdi-api</artifactId>
      <version>2.0</version>
    </dependency>
    <dependency>
      <groupId>org.jboss</groupId>
      <artifactId>jandex</artifactId>
      <version>2.0.5.Final</version>
    </dependency>
  • add minial required bootstrap configuration

public class App {
  public static void main(String[] args) {
    SeContainer container = SeContainerInitializer.newInstance()
                                                  .setClassLoader(App.class.getClassLoader())
                                                  .addPackages(App.class,
                                                               BeanManager.class)
                                                  .initialize();
    // happy hacking!
  }
}
  • build, run abd test

There are 2 options for fat jar available:

  • maven-assembly-plugin

  • capsule-maven-plugin

# jar
./mvnw -Passembly ; java -jar target/*-all.jar

# docker
./mvnw -Pcapsule ; ./mvnw docker-compose:up -P docker

maven profiles

qualifiersmore
./mvnw -Pcapsule,alternatives
java -jar target/*-all.jar
qualifiersmore
./mvnw -Pdependent,assembly
java -jar target/*-all.jar
qualifiersmore
./mvnw -Pany,capsule
java -jar target/*-all.jar
qualifiersmore
./mvnw -Pqualifiersmore,assembly
java -jar target/*-all.jar
getting-started
./mvnw -Pgetting-started,assembly
java -jar target/*-all.jar
interceptors
./mvnw -Pinterceptors,capsule
java -jar target/*-all.jar
logs
./mvnw -Plogs,capsule
java -jar target/*-all.jar
qualifiers
./mvnw -Pqualifiers,assembly
java -jar target/*-all.jar
default (simple)
./mvnw
./mvnw -Psimple,assembly
java -jar target/*-all.jar

other repositories:

links:

TODO:

Initially generated by using generator-jvm yeoman generator (java)