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

所属分类: 软件教程 / 编程开发 阅读数: 567
收藏 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

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

VS2017怎么打开类视图?

VS2017怎么打开类视图?VS2017编程开发很简单,想要打开类视图,该怎么打开呢?下面我们就来看看详细的教程,需要的朋友可以参考下
收藏 0 赞 0 分享

EmEditor怎么去重?

EmEditor是一款非常不错的文本编辑软件,该软件为广大用户提供了文字去重功能,那么EmEditor怎么去重呢?接下来小编就为大家带来解答,一起来看看吧
收藏 0 赞 0 分享

EmEditor怎么用宏 宏使用方法介绍

EmEditor是一款功能非常强大的文本编辑软件,该软件为广大用户提供了非常多的文字处理功能,宏就是其中之一,那么EmEditor怎么用宏呢?接下来小编就为大家带来解答,一起来看看吧
收藏 0 赞 0 分享

vs2015怎么编写移动端仿淘宝页面?

vs2015怎么编写移动端仿淘宝页面?Visual Studio 2015中想要编辑一个移动端的淘宝页面,该怎么编写呢?下面我们就来看看详细的教程,需要的朋友可以参考下
收藏 0 赞 0 分享

vs添加ASP.Net文件夹中各选项是什么意思?

vs添加ASP.Net文件夹中各选项是什么意思?Visual Studio中可以直接添加ASP.Net文件夹,其中文件夹各选项是什么意思?下面我们就来看看详细的教程,需要的朋友可以参考下
收藏 0 赞 0 分享

Authorware怎么添加运动图标?

Authorware怎么添加运动图标?Authorware制作媒体课件的时候,想要插入运动图标,该怎么插入呢?下面我们就来看看详细的教程,需要的朋友可以参考下
收藏 0 赞 0 分享

Authorware怎么插入擦除图标?

Authorware怎么插入擦除图标?Authorware中制作课件很简单,想要插入擦除图标,该怎么制作呢?下面我们就来看看详细的教程,需要的朋友可以参考下
收藏 0 赞 0 分享

Authorware课件怎么绘制圆角矩形?

Authorware课件怎么绘制圆角矩形?Authorware制作课件的时候,想要绘制圆角矩形,该怎么绘制呢?下面我们就来看看详细的教程,需要的朋友可以参考下
收藏 0 赞 0 分享

MySQL Workbench8.0中文汉化安装破解详细教程(附汉化补丁下载)

Mysql workbench8.0中文版是一款Mysql官方推出的数据库设计建模工具,可以用Mysql workbench中文版设计和创建新的数据库图示,建立数据库文档,下面带来的是Mysql workbench8.0官方64位汉化安装步骤,大家参考下
收藏 0 赞 0 分享

vs2013同名变量或函数高亮显示怎么设置?

vs2013同名变量或函数高亮显示怎么设置?vs2013代码可以添加高亮,想要让同名变量或函数高亮显示,该怎么设置呢?下面我们就来看看详细的教程,需要的朋友可以参考下
收藏 0 赞 0 分享
查看更多