Soc*_*tes 3 jsf barcode maven primefaces jsf-2
我试图从PrimeFaces Showcase中获取条形码,但是当我放置XHTML代码并让它在我当地的Wildfly 8中运行时,我只是得到完全垃圾.每个条形码的数量太大,QR码根本不起作用.
我相信我可能缺少Maven依赖,但我很难找到必要的依赖.
在文档之后,我想我必须barcode4j-light在版本中集成依赖项2.1,但我在Maven上找不到这个版本.
我该如何整合这个?我很感激每一个帮助!提前致谢!
我的Barcode.xhtml:
<!DOCTYPE html>
<html xmlns="http://www.w3c.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui"
xmlns:f="http://xmlns.jcp.org/jsf/core">
<h:head/>
<h:body>
<p:panelGrid columns="2">
<h:outputText value="Interleaved 2 of 5" />
<p:barcode value="0123456789" type="int2of5" />
<h:outputText value="Codabar" />
<p:barcode value="0123456789" type="codabar"/>
<h:outputText value="Code39" />
<p:barcode value="0123456789" type="code39" />
<h:outputText value="Code128" />
<p:barcode value="0123456789" type="code128"/>
<h:outputText value="EAN-8" />
<p:barcode value="20123451" type="ean8"/>
<h:outputText value="EAN-13" />
<p:barcode value="0123456789012" type="ean13"/>
<h:outputText value="UPC-A (PNG)" />
<p:barcode value="01234567895" type="upca" format="png"/>
<h:outputText value="UPC-E (Vertical)" />
<p:barcode value="01234133" type="upce" orientation="90"/>
<h:outputText value="PDF417" />
<p:barcode value="0123456789" type="pdf417"/>
<h:outputText value="DataMatrix" />
<p:barcode value="0123456789" type="datamatrix"/>
<h:outputText value="Postnet" />
<p:barcode value="0123456789" type="postnet"/>
<h:outputText value="QR" />
<p:barcode value="0123456789" type="qr"/>
</p:panelGrid>
</h:body>
</html>
Run Code Online (Sandbox Code Playgroud)
我的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>
<groupId>com.glasses</groupId>
<artifactId>primeWork</artifactId>
<version>1.0</version>
<packaging>war</packaging>
<name>primeWork</name>
<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>
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>5.1</version>
</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>
</project>
Run Code Online (Sandbox Code Playgroud)
所以barcode4j-light-2.1Maven资源库中没有.我们需要从SourceForge下载它.下载并解压后,转到build目录.该barcode4j-light罐子会在那里.
要将其安装到您当地的Maven仓库,请按照这些说明操作.基本上,从命令行(从builddir并假设你已经安装了Maven):
C:\...build>mvn install:install-file -Dfile=barcode4j-light.jar
-DgroupId=net.sf.barcode4j
-DartifactId=barcode4j-light
-Dversion=2.1
-Dpackaging=jar
Run Code Online (Sandbox Code Playgroud)
该命令应该全部在一行而不是按照您在此处看到的行分隔.然后,您只需将依赖项添加到项目中即可
<dependency>
<groupId>net.sf.barcode4j</groupId>
<artifactId>barcode4j-light</artifactId>
<version>2.1</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
你也需要这个
<dependency>
<groupId>net.glxn</groupId>
<artifactId>qrgen</artifactId> <!-- QR code support -->
<version>1.4</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
不像这样一步一步,但这在Prime Faces用户指南中有所描述.一旦我按照上述步骤,它对我有用.
| 归档时间: |
|
| 查看次数: |
3001 次 |
| 最近记录: |