使用netbeans搭建jsf+spring框架的方法

所属分类: 软件教程 / 编程开发 阅读数: 600
收藏 0 赞 0 分享

使用netbeans 搭建 JSF+SPRING 框架

spring版本使用4,jsf版本2.2

jsf的配置文件faces-config.xml


复制代码
代码如下:

<?xml version='1.0' encoding='UTF-8'?>
<faces-config version="2.0"
xmlns="<a href="http://java.sun.com/xml/ns/javaee">http://java.sun.com/xml/ns/javaee</a>"
xmlns:xsi="<a href="http://www.w3.org/2001/XMLSchema-instance">http://www.w3.org/2001/XMLSchema-instance</a>"
xsi:schemaLocation="<a href="http://java.sun.com/xml/ns/javaee">http://java.sun.com/xml/ns/javaee</a> <a href="http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd">http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd</a>">
<application>
<el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver>
</application>
</faces-config>

spring配置文件spring-config.xml


复制代码
代码如下:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="<a href="http://www.springframework.org/schema/beans">http://www.springframework.org/schema/beans</a>"
xmlns:xsi="<a href="http://www.w3.org/2001/XMLSchema-instance">http://www.w3.org/2001/XMLSchema-instance</a>"
xmlns:aop="<a href="http://www.springframework.org/schema/aop">http://www.springframework.org/schema/aop</a>"
xmlns:c="<a href="http://www.springframework.org/schema/c">http://www.springframework.org/schema/c</a>"
xmlns:context="<a href="http://www.springframework.org/schema/context">http://www.springframework.org/schema/context</a>"
xmlns:flow="<a href="http://www.springframework.org/schema/webflow-config">http://www.springframework.org/schema/webflow-config</a>"
xmlns:jee="<a href="http://www.springframework.org/schema/jee">http://www.springframework.org/schema/jee</a>"
xmlns:jms="<a href="http://www.springframework.org/schema/jms">http://www.springframework.org/schema/jms</a>"
xmlns:lang="<a href="http://www.springframework.org/schema/lang">http://www.springframework.org/schema/lang</a>"
xmlns:osgi="<a href="http://www.springframework.org/schema/osgi">http://www.springframework.org/schema/osgi</a>"
xmlns:p="<a href="http://www.springframework.org/schema/p">http://www.springframework.org/schema/p</a>"
xmlns:tx="<a href="http://www.springframework.org/schema/tx">http://www.springframework.org/schema/tx</a>"
xmlns:util="<a href="http://www.springframework.org/schema/util">http://www.springframework.org/schema/util</a>"
xmlns:jpa="<a href="http://www.springframework.org/schema/data/jpa">http://www.springframework.org/schema/data/jpa</a>"

xsi:schemaLocation="<a href="http://www.springframework.org/schema/beans">http://www.springframework.org/schema/beans</a> <a href="http://www.springframework.org/schema/beans/spring-beans-4.0.xsd">http://www.springframework.org/schema/beans/spring-beans-4.0.xsd</a>
<a href="http://www.springframework.org/schema/aop">http://www.springframework.org/schema/aop</a> <a href="http://www.springframework.org/schema/aop/spring-aop-4.0.xsd">http://www.springframework.org/schema/aop/spring-aop-4.0.xsd</a>
<a href="http://www.springframework.org/schema/context">http://www.springframework.org/schema/context</a> <a href="http://www.springframework.org/schema/context/spring-context-4.0.xsd">http://www.springframework.org/schema/context/spring-context-4.0.xsd</a>
<a href="http://www.springframework.org/schema/webflow-config">http://www.springframework.org/schema/webflow-config</a> <a href="http://www.springframework.org/schema/webflow-config/spring-webflow-config-2.0.xsd">http://www.springframework.org/schema/webflow-config/spring-webflow-config-2.0.xsd</a>
<a href="http://www.springframework.org/schema/jee">http://www.springframework.org/schema/jee</a> <a href="http://www.springframework.org/schema/jee/spring-jee-4.0.xsd">http://www.springframework.org/schema/jee/spring-jee-4.0.xsd</a>
<a href="http://www.springframework.org/schema/jms">http://www.springframework.org/schema/jms</a> <a href="http://www.springframework.org/schema/jms/spring-jms-4.0.xsd">http://www.springframework.org/schema/jms/spring-jms-4.0.xsd</a>
<a href="http://www.springframework.org/schema/lang">http://www.springframework.org/schema/lang</a> <a href="http://www.springframework.org/schema/lang/spring-lang-4.0.xsd">http://www.springframework.org/schema/lang/spring-lang-4.0.xsd</a>
<a href="http://www.springframework.org/schema/osgi">http://www.springframework.org/schema/osgi</a> <a href="http://www.springframework.org/schema/osgi/spring-osgi-1.2.xsd">http://www.springframework.org/schema/osgi/spring-osgi-1.2.xsd</a>
<a href="http://www.springframework.org/schema/tx">http://www.springframework.org/schema/tx</a> <a href="http://www.springframework.org/schema/tx/spring-tx-4.0.xsd">http://www.springframework.org/schema/tx/spring-tx-4.0.xsd</a>
<a href="http://www.springframework.org/schema/util">http://www.springframework.org/schema/util</a> <a href="http://www.springframework.org/schema/util/spring-util-4.0.xsd">http://www.springframework.org/schema/util/spring-util-4.0.xsd</a>
<a href="http://www.springframework.org/schema/data/jpa">http://www.springframework.org/schema/data/jpa</a> <a href="http://www.springframework.org/schema/data/jpa/spring-jpa.xsd">http://www.springframework.org/schema/data/jpa/spring-jpa.xsd</a>
">
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"
lazy-init="false">
<property name="locations">
<list>
<value>classpath*:jdbc.properties</value>
</list>
</property>
</bean>
<context:annotation-config/>
<context:component-scan base-package="cn.catr.lm.idc" />


<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<!--不使用persistence.xml 做如下配置-->
<property name="packagesToScan" value="cn.catr.lm.idc.po"/>
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"/>
</property>
<property name="jpaProperties">
<props>
<prop key="hibernate.connection.driver_class">${jdbc.driverClassName}</prop>
<prop key="hibernate.connection.url">${jdbc.url}</prop>
<prop key="hibernate.connection.username">${jdbc.username}</prop>
<prop key="hibernate.connection.password">${jdbc.password}</prop>
<prop key="hibernate.c3p0.min_size">10</prop>
<prop key="hibernate.hbm2ddl.auto">update</prop>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
</props>
</property>
</bean>

<!-- 配置事务管理器 -->
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>

<!-- 启用 annotation事务-->
<tx:annotation-driven transaction-manager="transactionManager"/>

</beans>

jdbc.properties文件


复制代码
代码如下:

jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/idc
jdbc.username=root
jdbc.password=111111

更多精彩内容其他人还在看

精易模块新手入门图文教程

精易模块是最好用的开源易模块,全中文命令,多个常用类功能,采用windows Api+核心命令打造,性能强大、使用简单、功能免费、免费开源,这篇文章主要介绍了精易模块新手入门图文教程,需要的朋友可以参考下
收藏 0 赞 0 分享

scratch3.0怎么制作会变色的鹦鹉动画?

scratch3.0怎么制作会变色的鹦鹉动画?scratch3.0中想要制作一个会变色的鹦鹉,该怎么制作这个效果呢?下面我们就来看看详细的教程,需要的朋友可以参考下
收藏 0 赞 0 分享

windows下jdk安装图解(覆盖安装报错)

这篇文章主要介绍了windows下jdk安装图解,覆盖安装报错,第一次安装和第二次安装区别,需要的朋友可以参考下
收藏 0 赞 0 分享

Java配置 JDK开发环境搭建及环境变量配置详细图文教程

这篇文章主要介绍了Java配置 JDK开发环境搭建及环境变量配置详细图文教程,需要的朋友可以参考下
收藏 0 赞 0 分享

IntelliJ IDEA搭建Android开发环境图文详解

这篇文章主要介绍了IntelliJ IDEA搭建Android开发环境图文详解,需要的朋友可以参考下
收藏 0 赞 0 分享

visual studio 2019的安装以及使用方法

这篇文章主要介绍了visual studio 2019的安装以及使用图文方法,一款专为帮助程序设计人员更好,设计更优质程序开发的功能强大,需要的朋友可以参考下
收藏 0 赞 0 分享

基于IntelliJ IDEA 13搭建Android集成开发环境(图文教程)

使用IntelliJ IDEA搭建Android集成开发环境,但是感觉不详细,所以打算自己整理一个详细的图文教程,希望能对新手(包括自己)有所帮助,需要的朋友可以参考下
收藏 0 赞 0 分享

代码自动生成工具ASP.NET Maker 2020安装及激活教程(附注册机下载)

ASP.NET Maker 2020如何激活?ASP.NET Maker 2020一款功能强大的自动化代码生成器,下文中详细的介绍了本软件的安装及激活教程,另附上注册机下载,感兴趣的朋友不妨阅读下文内容,参考一下吧
收藏 0 赞 0 分享

python运行环境搭建和pycharm的安装配置及汉化(零基础小白版)

写这篇文章主要是介绍一下python的环境搭建和pycharm的安装配置,适合零基础的同学观看。这篇文章你会学到python的环境搭建和python比较好用的IDE pycharm的安装与基础配置
收藏 0 赞 0 分享

IntelliJ WebStorm 2020.3.3 最新激活教程 附汉化补丁安装教程

今天脚本小编给大家分享的是IntelliJ WebStorm 2020.3.3最新激活补丁和汉化补丁的安装激活教程,此款软件的激活比较麻烦,每个版本激活方法都不一样,所以小编就给大家分享了详细的安装激活教程,此教程是小编一步一步安装得来,所以真实有效,大家放心按照步骤安装即可
收藏 0 赞 0 分享
查看更多