gpt4 book ai didi

maven - PrimeFaces 条码不起作用?

转载 作者:行者123 更新时间:2023-12-01 10:45:35 28 4
gpt4 key购买 nike

我试图从运行的 PrimeFaces Showcase 中获取条形码,但是当我放置 XHTML 代码并让它在我本地的 Wildfly 8 中运行时,我得到的完全是垃圾。每个条形码的数字太大,二维码根本不起作用。

我相信我可能缺少 Maven 依赖项,但我很难找到必要的依赖项。

按照文档,我想我必须在 2.1 版本中集成对 barcode4j-light 的依赖,但我在 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>

我的 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>

最佳答案

因此 barcode4j-light-2.1 在 Maven 存储库中不可用。我们需要从SourceForge下载它.下载并解压缩后,转到 build 目录。 barcode4j-light jar 将在那里。

要将其安装到本地 Maven 存储库,请遵循 these instructions .基本上,从命令行(从 build 目录并假设您安装了 Maven):

C:\...build>mvn install:install-file -Dfile=barcode4j-light.jar 
-DgroupId=net.sf.barcode4j
-DartifactId=barcode4j-light
-Dversion=2.1
-Dpackaging=jar

该命令应全部在一行中,而不是像您在此处看到的那样以行分隔。然后你可以将依赖添加到你的项目中

<dependency>
<groupId>net.sf.barcode4j</groupId>
<artifactId>barcode4j-light</artifactId>
<version>2.1</version>
</dependency>

你还需要这个

<dependency>
<groupId>net.glxn</groupId>
<artifactId>qrgen</artifactId> <!-- QR code support -->
<version>1.4</version>
</dependency>

不是像这样一步一步来的,而是在 Prime Faces User Guide 中描述的.一旦我按照上述步骤操作,它对我有用。

关于maven - PrimeFaces 条码不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26686351/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com