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

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

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

Texmaker使用方法、Latex的优缺点详细介绍

下半学期过半,读硕士的同学们快要准备论文了。这个帖子估计要花上几天才能完成。到底写道什么程度看我耐心好了
收藏 0 赞 0 分享

Html标签简明教程

html标签的使用:字体、列表、图像、表格、超链接、表单等,学会了这些标签就可以写网页代码了。
收藏 0 赞 0 分享

eclipse安装教程(图文)

做java开发的朋友,都应该有一个适合自己的开发环境,而eclipse就是这么一个适合java开发的集成环境,完全免费,而且免安装,是java开发人员的必备平台。下面,小编就带大家来看看怎么安装和使用eclipse
收藏 0 赞 0 分享

eclipse使用教程(图文)

很多人都知道要用eclipse来做java开发,但很多的新手朋友却不知道怎么下载和安装eclipse。下面给你介绍一下怎么下载和安装eclipse来用于自己的学习或者项目开发
收藏 0 赞 0 分享

php session的生存周期详解示例

详解php session的生存周期:session 在何时被创建、session 何时被删除、session自动失效等一系列的动作。
收藏 0 赞 0 分享

python 开发利器UliPad(图文详细介绍)

今天给大家介绍一个python 开发利器---UliPad(图文说明),让你能更好的使用UliPad开发python,我感觉比Eclipse还要好用,不信你试试。
收藏 0 赞 0 分享

ubuntu安装配置java环境(图)

在ubuntu(linux)下安装配置java环境(图),还有Eclipse IDE的安装方法,做完这些,你就可以在LINUX下开发JAVA了。
收藏 0 赞 0 分享

很简单的Eclipse连接MySQL数据库方法

看完下面5个步骤你就可以使用Eclipse连接MySQL数据库了,简单的方法就可以做到Eclipse连接MySQL数据库。
收藏 0 赞 0 分享

Wing IDE搜索工具介绍(图)

Wing IDE编辑器的搜索工具提供了一个基于友好GUI的搜索和替换工具。
收藏 0 赞 0 分享

Wing IDE如何进行命令行调试

Wing IDE专业的调试探针提供了一种强大的方法来发现和解决复杂的错误。下面看看如何使用。
收藏 0 赞 0 分享
查看更多