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

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

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

nginx 0.8.54/1.0.0 在cygwin环境下的编译(包括 nginx_mod_h264_streaming-2.2.7)

由于测试需要在WIN平台上进行.264的MP4文件的拖动功能,而nginx windows官方版本不包含nginx_mod_h264_streaming-2.2.7模块,所以才有了本文。
收藏 0 赞 0 分享

在windows下使用淘宝的nginx插件 nginx_concat_module (附下载地址)

本文所作的工作主要是是向大家展示一个windows版本的具有文件合并功能的nginx。
收藏 0 赞 0 分享

把其他C/C++编译器集成到VC2005中的方法

在Visual C++2005中,如何调用其它编译器编译.cpp文件呢?换句话说,如何把其它编译器集成到VC2005的IDE中呢?
收藏 0 赞 0 分享

用EXCEL表格和软件打开xml文件的方法具体步骤

XML是Extensible Markup Language的简写,一种扩展性标识语言。
收藏 0 赞 0 分享

Visual Studio IDE 实用小技巧(附打包下载)

看到《Visual Studio 2010 实用功能总结》2篇文章大家都比较喜欢,我也来补充一些Visual Studio的实用小技巧。
收藏 0 赞 0 分享

Visual Studio 2010 正式版激活的两种方法小结

全球开发者最为瞩目的Visual Studio 2010开发工具在4月12日正式发布,现为大家制作一个简单的破解教程有两种方法,操作不一样,原都一样(针对旗舰版,其他版本方法一样):
收藏 0 赞 0 分享

EditGod 灵者编辑(正则与文本加解密)使用教材

今天发现一款不错的支持正则与文本加解密的工具EditGod,就这个工具我们就做个简单的教程,体验下功能。
收藏 0 赞 0 分享

VS2010执行剪贴、复制时,提示内存不足的官方补丁

在VS 2010中执行剪切/拷贝文本操作时,有时会工作不正常,我们已经收到好几份这样的问题报告了。
收藏 0 赞 0 分享

Zend Guard 5.0 key 注册码(php zend加密)

zend guard 可以实现对php应用的脚本进行加密保护和对php应用的产品进行商业许可证管理
收藏 0 赞 0 分享

Zend Studio 7 常用的快捷键整理

分享Zend Studio 7快捷键
收藏 0 赞 0 分享
查看更多