Java SE中的Bootstrap CDI 2.0
生活随笔
收集整理的這篇文章主要介紹了
Java SE中的Bootstrap CDI 2.0
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
抽象
這是在Java SE應用程序中引導CDI 2.0的快速參考。
CDI 2.0(JSR 365)
Maven依賴
<dependency><groupId>org.jboss.weld.se</groupId><artifactId>weld-se-core</artifactId><version>3.0.2.Final</version> </dependency>beans.xml
文件位置是/META-INF/beans.xml 。 這個文件是可選的,盡管我發現它仍然很不錯。
<beans version="2.0" xmlns="http://xmlns.jcp.org/xml/ns/javaee"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_2_0.xsd" bean-discovery-mode="all" ><scan><exclude name="org.jboss.weld.**" /></scan> </beans>Java SE應用程序
package org.ferris.cdi.example.main;import javax.enterprise.inject.se.SeContainer; import javax.enterprise.inject.se.SeContainerInitializer;/*** The main() method for this application** @author <a href="mailto:mjremijan@yahoo.com">Mike Remijan</a>*/ public class Main {public static void main(String[] args) {SeContainer container= SeContainerInitializer.newInstance().initialize();Main main= container.select(Main.class).get();//. . .} }摘要
就是這樣...享受!
翻譯自: https://www.javacodegeeks.com/2018/01/bootstrap-cdi-2-0-java-se.html
總結
以上是生活随笔為你收集整理的Java SE中的Bootstrap CDI 2.0的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 工信部将加强网站备案、域名等网络管理
- 下一篇: 威马汽车“借壳”