gpt4 book ai didi

java - 如何在 Netbeans 中从 Maven 安装 PrimeFaces?我收到警告,标签库 http ://primefaces. org/ui 不存在

转载 作者:塔克拉玛干 更新时间:2023-11-03 02:52:14 25 4
gpt4 key购买 nike

我测试部署这个 example来自 PrimeFaces。

我不知道为什么它不起作用。我收到此错误消息:

警告:此页面调用 xml 命名空间 http://primefaces.org/ui用前缀 p 声明,但该命名空间不存在 taglibtrary

我关注这个tutorial正确安装 jar 。我下载了 Primefaces jar 文件并将其添加到 resources目录到 WAR 文件中。

    <dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>3.3</version>
<type>jar</type>
</dependency>

我还将 Primefaces.jar 文件添加到 Glassfish 的/modules 目录中,并将模块的名称添加到 default-web.xml 文件中。它不起作用。

我错过了什么?

编辑 2 我是正确的 POM 文件是问题所在:

<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.DX_57</groupId>
<artifactId>History-Module-57</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>

<name>History-Module-57</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>6.0</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>3.3</version>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
<version>4.2.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.compendium</artifactId>
<version>4.2.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>osgi-cdi-api</artifactId>
<version>3.1-b41</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
<pluginManagement>

<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.1.0</version>
<extensions>true</extensions>
<configuration>
<supportedProjectTypes>
<supportedProjectType>ejb</supportedProjectType>
<supportedProjectType>war</supportedProjectType>
<supportedProjectType>bundle</supportedProjectType>
<supportedProjectType>jar</supportedProjectType>
</supportedProjectTypes>
<instructions>
<!-- Read all OSGi configuration info from this optional file -->
<_include>-osgi.properties</_include>
<!-- By default, we don't export anything -->
<Export-Package>!*.impl.*, *</Export-Package>
<DynamicImport-Package>javax.*, org.*, com.sun.faces.*</DynamicImport-Package>
<Import-Package>*;resolution:=optional</Import-Package>
<Embed-Dependency>*;scope=compile|runtime;inline=false</Embed-Dependency>
<Embed-Transitive>true</Embed-Transitive>
<Embed-Directory>WEB-INF/lib</Embed-Directory>
<Embed-StripVersion>false</Embed-StripVersion>
<Embed-StripGroup>true</Embed-StripGroup>
<Bundle-ClassPath>.,WEB-INF/classes</Bundle-ClassPath>
</instructions>
</configuration>
<executions>
<execution>
<id>bundle-manifest</id>
<phase>process-classes</phase>
<goals>
<goal>manifest</goal>
</goals>
</execution>
<execution>
<id>bundle-install</id>
<phase>install</phase>
<goals>
<goal>install</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin> <!-- Need to use this plugin to build war files -->
<artifactId>maven-war-plugin</artifactId>
<groupId>org.apache.maven.plugins</groupId>
<!-- Use version 2.1-beta-1, as it supports the new property failOnMissingWebXml -->
<version>2.1-beta-1</version>
<configuration>
<archive>
<!-- add bundle plugin generated manifest to the war -->
<manifestFile>
${project.build.outputDirectory}/META-INF/MANIFEST.MF
</manifestFile>
<!-- For some reason, adding Bundle-ClassPath in maven-bundle-plugin
confuses that plugin and it generates wrong Import-Package, etc.
So, we generate it here.
-->
<manifestEntries>
<Bundle-ClassPath>WEB-INF/classes/
</Bundle-ClassPath>
</manifestEntries>
</archive>
<!-- We don't have a web.xml -->
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.1</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>6.0</version>
<type>jar</type>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<compilerArguments>
<endorseddirs>${endorsed.dir}</endorseddirs>
</compilerArguments>
</configuration>
</plugin>
<plugin>
<!-- Enable this plugin for all modules -->
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>glassfish-repo</id>
<name>The Glassfish repository</name>
<url>http://download.java.net/maven/glassfish/</url>
</repository>
<repository>
<id>prime-repo</id>
<name>PrimeFaces Maven Repository</name>
<url>http://repository.primefaces.org</url>
<layout>default</layout>
</repository>
</repositories>
<description>Module History Module</description>
</project>

必须添加这些行才能使 Primefaces 正常工作:

<instructions>
<!-- Read all OSGi configuration info from this optional file -->
<_include>-osgi.properties</_include>
<!-- By default, we don't export anything -->
<Export-Package>!*.impl.*, *</Export-Package>
<DynamicImport-Package>javax.*, org.*, com.sun.faces.*</DynamicImport-Package>
<Import-Package>*;resolution:=optional</Import-Package>
<Embed-Dependency>*;scope=compile|runtime;inline=false</Embed-Dependency>
<Embed-Transitive>true</Embed-Transitive>
<Embed-Directory>WEB-INF/lib</Embed-Directory>
<Embed-StripVersion>false</Embed-StripVersion>
<Embed-StripGroup>true</Embed-StripGroup>
<Bundle-ClassPath>.,WEB-INF/classes</Bundle-ClassPath>
</instructions>

但我注意到一个很奇怪的问题。例如,我可以使用没有 managedbean 的简单 PrimeFaces 标签 <p:spinner>但是如果我想将标签与托管 bean 一起使用,则找不到 bean。也许它们是不可见的?

最佳答案

我只是按照 Primefaces 下载指南中的步骤操作:

http://primefaces.org/downloads.html

使用 Maven 下载

PrimeFaces 发行版部署在 PrimeFaces 存储库中,要让 maven 知道此存储库,请将以下存储库定义添加到存储库部分的 pom.xml 中。

<repository>  
<id>prime-repo</id>
<name>PrimeFaces Maven Repository</name>
<url>http://repository.primefaces.org</url>
<layout>default</layout>
</repository>

并添加依赖配置为;

<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>3.3</version>
</dependency>

之后,我将 Primefaces 存储库添加到我的 Nexus 安装中,它按预期工作。

希望对你有帮助!

关于java - 如何在 Netbeans 中从 Maven 安装 PrimeFaces?我收到警告,标签库 http ://primefaces. org/ui 不存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10818367/

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