使用Intellij Idea+Gradle 搭建Java 本地開發環境
專案搭建採用技術棧為:Spring+Spring MVC+Hibernate+Jsp+Gradle+tomcat+mysql5.6
搭建環境文件目錄結構說明:
- 使用Intellj Idea 搭建專案過程詳解
- 專案各配置檔案講解及部署
- 各層包功能講解&專案搭建完畢最終效果演示圖
- 專案中重要程式碼講解
- webapp資料夾下分層詳解
- 配置tomcat 執行環境
1. 使用Intellj Idea 搭建專案過程詳解
1.1 開啟Intellj Idea
Intellj idea 截圖
1.2 操縱 Intellj Idea 工具欄 新建專案
操縱idea 工具欄
使用Gradle建立專案
完善專案資訊
設定Gradle
確定專案資訊
選擇New Window
初始化專案結構截圖
需要說明的是,最初建立的專案檢視是不完整的,包括webapp資料夾下沒有web.xml,以及src包下缺少Java資料夾(放置java原始碼檔案),Resources資料夾(放置專案配置檔案)。
我們繼續做以下操作,使得專案的結構符合web 應用專案的層級標準。
操縱工具欄為專案新增 web.xml全域性配置檔案
出現如下檢視:
新建 web.xml檔案
設定web.xml檔案儲存位置
接下來:單擊main資料夾按照如下操作:
手動建立src中main資料夾下java目錄
輸入java 資料夾名稱
點選ok,再按照上圖操作操作一遍,輸入檔名為resources
最終的結構圖如下圖所示:
專案最終結構圖
2. 專案各配置檔案講解及部署
完成了專案的初始化結構建立,接下來我們需要來建立配置檔案。
首先是resources資料夾下的配置檔案
2.1 resources下資原始檔截圖:(最終配置的結果)
專案所需配置檔案最終配置結果
2.2 data-access-applicationContext.xml
主要管理資料庫訪問元件
- xml version="1.0" encoding="UTF-8"
- <beansxmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:context="http://www.springframework.org/schema/context"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd
- http://www.springframework.org/schema/context
- http://www.springframework.org/schema/context/spring-context.xsd
- ">
- <!-- 配置自動掃描的包 -->
- <context:component-scanbase-package="com.fxmms"use-default-filters="false">
- <context:include-filtertype="regex"expression="com.fxmms.*.*.dao.*"/>
- <context:include-filtertype="regex"expression="com.fxmms.*.dao.*"/>
- </context:component-scan>
- <!-- 配置資料來源 -->
- <context:property-placeholderlocation="classpath:db.properties"/>
- <beanid="dataSource"class="org.springframework.jdbc.datasource.DriverManagerDataSource">
- <propertyname="driverClassName"value="${jdbc.driverClass}"/>
- <propertyname="url"value="${jdbc.jdbcUrl}"/>
- <propertyname="username"value="${jdbc.user}"/>
- <propertyname="password"value="${jdbc.password}"/>
- </bean>
- <!--配置hibernate SessionFactory-->
- <beanid="sessionFactory"
- class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
- <propertyname="dataSource"ref="dataSource"></property>
- <propertyname="hibernateProperties">
- <props>
- <propkey="hibernate.dialect">${dataSource.hibernate.dialect}</prop>
- <propkey="hibernate.show_sql">${dataSource.hibernate.show_sql}</prop>
- <propkey="hibernate.format_sql">true</prop>
- <!--負責自動建立資料表,基本上不能開啟註釋,否則所有的資料庫中表資訊都會被刪除,重新建立-->
- <!-- <prop key="hibernate.hbm2ddl.auto">create</prop> -->
- </props>
- </property>
- <!-- <property name="hibernate.jdbc.batch_size" value="50"></property> -->
- <propertyname="packagesToScan">
- <list>
- <value>com.fxmms.*.*.domain</value>
- <value>com.fxmms.*.domain</value>
- </list>
- </property>
- </bean>
- <!--jdbcTemplate start -->
- <beanid="jdbcTemplate"class="org.springframework.jdbc.core.JdbcTemplate">
- <propertyname="dataSource"ref="dataSource"></property>
- </bean>
- <!--Spring JDBC 中操作 LOB 資料 -->
- <beanid="lobHandler"class="org.springframework.jdbc.support.lob.DefaultLobHandler"
- lazy-init="true"></bean>
- <!-- 配置JPA部分 -->
- <!-- 配置JPA的EntityManagerFactory -->
- <!-- <bean id="entityManagerFactory"
- class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
- <property name="dataSource" ref="dataSource"></property>
- <property name="jpaVendorAdapter">
- <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"></bean>
- </property>
- <property name="packagesToScan" value="com.fxmms"></property>
- <property name="jpaProperties">
- <props>
- <prop key="hibernate.ejb.naming_strategy">org.hibernate.cfg.ImprovedNamingStrategy</prop>
- <prop key="hibernate.hbm2ddl.auto">update</prop>
- <prop key="hibernate.show_sql">true</prop>
- <prop key="hibernate.format_sql">true</prop>
- <prop key="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBDialect</prop>
- <prop key="hibernate.cache.use_second_level_cache">true</prop>
- <prop key="hibernate.cache.region.factory_class">org.hibernate.cache.ehcache.EhCacheRegionFactory
- </prop>
- <prop key="hibernate.cache.use_query_cache">true</prop>
- </props>
- </property>
- <!–使用二級快取–>
- <property name="sharedCacheMode" value="ENABLE_SELECTIVE"></property>
- </bean>
- <!– 配置事務 –>
- <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
- <property name="entityManagerFactory" ref="entityManagerFactory"></property>
- </bean>-->
- <!-- <!– 配置SpringData部分 –>
- <jpa:repositories base-package="com.fxmms"
- entity-manager-factory-ref="entityManagerFactory">
- </jpa:repositories>-->
- </beans>
2.3 service-applicationContext.xml
主要管理業務邏輯元件,包括對資料庫訪問的事務控制,以及定時任務。
- xml version="1.0" encoding="UTF-8"
- <beansxmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:context="http://www.springframework.org/schema/context"
- xmlns:aop="http://www.springframework.org/schema/aop"
- xmlns:task="http://www.springframework.org/schema/task"
- xmlns:tx="http://www.springframework.org/schema/tx"
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
- http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
- http://www.springframework.org/schema/aop
- http://www.springframework.org/schema/aop/spring-aop.xsd
- http://www.springframework.org/schema/tx
- http://www.springframework.org/schema/tx/spring-tx.xsd
- http://www.springframework.org/schema/task
- http://www.springframework.org/schema/task/spring-task.xsd">
- <aop:aspectj-autoproxy/>
- <!--設定定時任務-->
- <task:annotation-driven/>
- <context:component-scanbase-package="com.fxmms.www"use-default-filters="false">
- <context:include-filtertype="annotation"
相關推薦
使用Intellij Idea+Gradle 搭建Java 本地開發環境
專案搭建採用技術棧為:Spring+Spring MVC+Hibernate+Jsp+Gradle+tomcat+mysql5.6搭建環境文件目錄結構說明:使用Intellj Idea 搭建專案過程詳解專案各配置檔案講解及部署各層包功能講解&專案搭建完畢最終效果演示圖
「問題解決」利用IntelliJ IDEA搭建Java Web開發環境
為了應對今年火燒眉毛的春招與秋招,最近開始學習JavaWeb開發。 在進行JavaWeb應用開發前,需要先把整個開發環境搭建好。例如,需要安裝Java開發工具包JDK、Web伺服器(Tomcat)和IDE開發工具。 本人最近學習的書籍中,是利用Eclipse作為JavaWeb應用開發工具。由
使用IntelliJ IDEA和maven搭建java web項目
生成 cat maven 原始的 cti intel tid rec 工程 File -> New Module,進入創建項目窗口。 點擊Next,填寫GroupId、ArtifactId和Version 填寫Module name,要保證maven中央倉
搭建 Java Web 開發環境
此實驗教大家如何配置 JDK 、Tomcat 和 Mysql 安裝 JDK JDK 是開發Java程式必須安裝的軟體,檢視一下 yum 源裡面的 JDK: yum list java* 選擇適合本機的JDK,並安裝: yum install
搭建Java Web 開發環境
說明: 本教程中使用的騰訊雲,IP地址是http://123.207.7.49:8080 ,這些設定可能會有所不同,你需要根據不同情況進行修改。 1.啟動伺服器進入雲主機,可以看到以下畫面! 2. 安裝 JDK JDK 是開發Java程式必須安裝的軟體,我們
Centos下Docker使用映象和DockerFile方式搭建JAVA Web 開發環境
1、環境1、1先決條件1.必須是64位CPU架構的計算機,Docker目前不支援32位CPU;2.執行Linux3.8或更高版本核心,CentOS時核心必不小於3.10;3.核心必須支援一種合適的儲存驅動,可以是Device Manager、AUFS、vfs、btrfs、以及
mac搭建java web開發環境
新入手mac筆記本,需要重新搭建java開發環境。 之前一直使用的環境: myeclipse(自帶各種外掛) weblogic oracle 本次在mac上準備搭建的環境: ecplise(官網下載,注意有多個版本,下載《Eclipse IDE for Java EE De
開發環境-Windows下搭建JAVA Web開發環境(含Tomcat+MySQL)-過程記錄
一、新建雲伺服器 (請注意,文中連結均在“http”中“h”後和“www”第一個“w”後多加一“ ”) 1、在"teng xun 雲",新建雲伺服器:Windows Server 2012 R2 標準版 64位中文版 2、登入雲伺服器:h ttps://w
Linux下搭建Java web開發環境
概述: 1.Linux環境一臺(VM或者雲伺服器,本教程採用百度雲伺服器BCC)Baidu Cloud Compute 伺服器配置說明:centos6.5,jdk7_64 ,tomcat7 2.新建幾個目錄,/software /data /log /backup,用來存放jdk、t
配置IntelliJ IDEA 13的SBT和Scala開發環境
對於scala的開發環境,公認最好的IDE是IntelliJ IDEA+scala&sbt外掛。sbt(Simple Build Tool,a build tool for Scala.)是scala專用的構建工具,使用scala語言編寫,配置比maven等構建工具
Mac OS X 10.9下搭建java web開發環境之一 開啟和配置本機的Apache服務
概要: 可能大多數人沒有注意到,Mac OS X 其實內建了 Apache 伺服器,可以很簡單的啟動web服務。Apple 將 Apache “封裝”起來了,通常的使用者介面中沒有任何直接對其進行操作設定的部分。本文簡介Mac OS X 中怎樣通過Apache啟動web服務
Java Web學習(3):Win7 64位作業系統搭建Java Web開發環境
一搭建Java Web開發環境的總體概覽 工欲善其事必先利其器。學會搭建Java Web開發環境是學習JSP動態網站開發的最基本技能之一。主要介紹在 Windows 7
初學Java Web(2)——搭建Java Web開發環境
config 官方網站 thead .com view eve 微信 停止 記錄 初學Java Web(2)——搭建Java Web開發環境 雖然說 html 和 css 等前端技術,是對於 Web 來說不可或缺的技術,但是
Hadoop Intellij IDEA本地開發環境搭建
首先我們需要新建一個java工程用於開發Mapper與Reducer,同時我們也需要匯入hadoop的依賴包,這些包可以在hadoop的 share/hadoop 目錄下找到,你可以把這些包單獨取出來作為之後專案的備用。 開啟Project Structure
IDEA如何快速搭建Java開發環境,IntelliJ IDEA mac新手入門
images jdk版本 color port servers 技術分享 -o 本地倉庫 serve 作為IntelliJ IDEA mac新手,IDEA如何快速搭建Java開發環境呢?今天小編就給大家帶來了IntelliJ IDEA mac使用教程,想知道IDEA如何快速
JAVA 基礎--開發環境IDEA 搭建
com target 註冊碼 獲取 nbsp activate 配置 選擇 ref 1.下載IDEA (500M+) 2.激活。 在網站http://idea.lanyus.com/中獲取註冊碼,填入Activation code中; 然後點擊Activate即可
Spark本地開發環境配置(windows/Intellij IDEA 篇)
前言 Intellij IDEA是一個蠻不錯的IDE,在java/scala領域深得人心。筆者之前使用的是Eclipse那一套開發環境,雖然也不錯,但忍不住好奇心的驅使,折騰了一下IDEA,將自己摸索過程總結一下,方便Spark愛好者參考。 1.配置前提 J
搭建struts2 專案開發環境——(使用Intellij IDEA+Maven+struts2 )
Struts的介紹 Struts的是阿帕奇軟體基金會(ASF)贊助的一個開源專案。它最初是雅加達專案中的一個子專案,並在2004年3月成為ASF的頂級專案。它通過採用JavaServlet / JSP技術,實現了基於JavaEEWeb應用的M
利用Intellij Idea在windows搭建spark 開發環境(含打jar包過程)(一)
本文的目的:利用Intellij Idea在windows搭建spark 開發環境 環境:windows 10, intellij idea2016.1.1, spark 1.6.2(HDP),hadoop2.7.3(HDP),scala 2.10.5(編譯環境), sbt
使用IDEA和gradle搭建Spring MVC和MyBatis開發環境
1. 概述 Gradle是一個基於Apache Ant和Apache Maven概念的專案自動化建構工具。 它使用一種基於Groovy的特定領域語言(DSL)來宣告專案設定,拋棄了基於XML的各種繁瑣配置。 Spring MVC屬於SpringFrameWork的後續產品,已經融合 在Spring W