前言:

  这两天为了巩固easyui的各个控件用法,搭建了一个简易的框架用于开发,大家可以用来参考,如果发现文章中有哪些不正确不合理的地方,也请各位不吝赐教,感激不尽。文章最下面有源码,可以用于参考。整个框架共分三层controller service serviceImpl,并且包括easyui的整合。

框架的目录:

  

一:创建项目

打开IntelliJ IDEA软件,点击File-New-Project创建项目

选中Spring Initializr 点击next

填写项目名 点击finish  注意:刚刚创建好的项目可能会自动引包,这里可以暂时暂停,因为我们后面是要修改pom.xml文件的内容的。

创建之后的项目路径如下:

二:修改配置,部分代码

点击File-setting 搜索maven

修改成功之后,修改下三个文件的内容,之后重新引包 三个文件分别是pom.xml  (这个文件名称是跟你创建项目时候的名称对应生成的)Application.properties

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.14.RELEASE</version>
<relativePath/> <!-- lookup parent from repository --> </parent>
<groupId>com.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>demo</name>
<packaging>war</packaging>
<description>Demo project for Spring Boot</description> <properties>
<java.version>1.8</java.version>
</properties> <dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency> <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<!--&lt;!&ndash;服务器&ndash;&gt;-->
<!-- <scope>provided</scope>-->
<!--本地-->
<scope>compile</scope>
</dependency> <dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.2.0</version>
<!--<version>12.1.0</version>-->
</dependency> <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<version>1.5.14.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency> <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency> <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies> <build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.*</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.*</include>
</includes>
</resource>
</resources>
</build>
</project>

pom.xml

启动类TmApplication

package com.example.tm;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer; @SpringBootApplication
public class TmApplication extends SpringBootServletInitializer { @Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return builder.sources(TmApplication.class);
} public static void main(String[] args) {
SpringApplication.run(TmApplication.class, args);
}
}

TmApplication

Application.properties  注意:数据库连接地址账号和密码都改成自己的就可以了

server.port=8080
server.application.name=demo spring.datasource.url=jdbc:oracle:thin:@system:1521/orcl
spring.datasource.username=ORCL
spring.datasource.password=orcl
spring.datasource.driver-class-oracle.jdbc.driver.OracleDriver spring.thymeleaf.suffix=.html
spring.thymeleaf.mode=HTML5
spring.thymeleaf.encoding=UTF-8
#热部署文件,页面不产生缓存,及时更新
spring.thymeleaf.cache=false
spring.resources.chain.strategy.content.enabled=true
spring.resources.chain.strategy.content.paths=/**

Application.properties

三:引入easyui

在static文件夹下先创建一个文件easyui

创建之后可以修改下显示的格式,有的人显示是下面这种‘点’连接的,我们改成树的会对结构看的更清楚

修改成树状结构的方法。

从网上下载easyui的包

将解压之后的内容直接复制到static文件夹下

这里因为test文件我们暂时不用,所以可以先屏蔽掉,不屏蔽启动的时候可能会报错。

四:后台代码

参考此目录进行创建

进入页面暂时只需要controller层,这里先将整个框架写好。要注意的是后台类,方法上的注解不要写错。由于暂时没有与后台交互,所以数据库不需要创建表。但是上面配置文件中,还是需要指定数据库的地址账号密码,否则启动项目会报错

package com.example.tm.report.controller;

import com.example.tm.report.service.reportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; @Controller
@RequestMapping("/report")
public class reportController { @Autowired
private reportService reportservice; /**
* 功能:报表
* 创建人:tm
* 时间:2019-12-28
*/
@GetMapping(value = "/report")
public String report(){
return "/report/report";
} }

reportController

reportService

package com.example.tm.report.service;

import org.springframework.stereotype.Service;

@Service("reportService")
public interface reportService { }

reportService

ReportServiceImpl

package com.example.tm.report.service.Impl;

import com.example.tm.report.service.reportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service; @Service("reportService")
public class ReportServiceImpl implements reportService { @Autowired
private JdbcTemplate jdbcTemplate; }

ReportServiceImpl

五:前台代码

参考此目录进行创建

注意:需要确认的几个地方

  1. link和script标签指定的easyui相关路径地址名称一定要正确

  2. 在js里如果要写js代码 要写在  /*<![CDATA[*/      /*]]>*/之内

<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title>报表</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css" href="../easyui/themes/default/easyui.css"/>
<link rel="stylesheet" type="text/css" href="../easyui/themes/icon.css"/>
<script type="text/javascript" src="../easyui/jquery.min.js"></script>
<script type="text/javascript" src="../easyui/jquery.easyui.min.js"></script>
<script type="text/javascript" src="../easyui/datagrid-export.js"></script>
<script type="text/javascript" src="../easyui/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript">
/*<![CDATA[*/ /*]]>*/
</script>
</head>
<body>
<div class="easyui-layout" style="width:100%;height:1000px;" fit="true">
<div id="tb" style="padding:3px">
<span>开始时间</span>
<input type="text" class="easyui-datebox" id="starttime"/>
<span>结束时间</span>
<input type="text" class="easyui-datebox" id="endtime"/>
<span>所在班组</span>
<select id = "ProjectTree" class="easyui-combotree" url="getClassGroupTree" name="city" style="width:156px;"/>
<a href="#" class="easyui-linkbutton" iconCls="icon-ok" onclick="doSearch()">查询</a>
<a href="#" class="easyui-linkbutton" iconCls="icon-ok" onclick="toExcel()">导出</a>
</div>
</div>
</body>
</html>

report.html

六:启动项目

启动项目分为两种,正常启动和debug模式启动

如果启动之后如下图所示没有报错,浏览器中直接输入  http://localhost:8080/report/report 就可以了(8080是application.properties文件中配置的,可以自行修改)

显示效果:

总结:此框架没有太深的技术,适用于刚刚接触springboot和开始学习搭框架的小伙伴们,接下来的文章里我会依据easyui为基础来完善各种easyui控件的用法,感兴趣的小伙伴可以查看我的博客springboot分类中的内容,如果文章有那些不合理不正确的内容,也请各位大神不吝赐教,小编感激不尽。

持续更新!!!

IntelliJ IDEA+springboot+jdbctemplet+easyui+maven+oracle搭建简易开发框架(一)的更多相关文章

  1. 搭建SpringBoot+dubbo+zookeeper+maven框架(一)

    这几天项目还没来,所以就自己试着参考网上的一些资料,搭建了一个SpringBoot+dubbo+zookeeper+maven框架,网上参考的很多资料照着他们一步一步搭建,最后很多都运行不通,很是郁闷 ...

  2. 使用IntelliJ IDEA和Maven管理搭建Web开发环境(以Spring MVC为例)(二)

    前言:在使用IntelliJ IDEA和Maven管理搭建Web开发环境(以Spring MVC为例)(一)中已经介绍了如何对web基础环境进行搭建,这里主要演示,如何对spring环境进行搭建,然后 ...

  3. 使用IntelliJ IDEA和Maven管理搭建Web开发环境(以Spring MVC为例)(一)

    前言:原来一直使用MyEclipse,换工作后,新公司使用IDEA,初识IDEA发现,哇,它的快捷键可真多啊,但是一路用下来,觉得非常的好用,特别是利用Maven管理,那简直叫一个爽.当然笔者在使用过 ...

  4. 搭建SpringBoot+dubbo+zookeeper+maven框架(二)

    上一篇文章是关于搭建SpringBoot+dubbo+zookeeper+maven框架的,但是里面的功能还不够完善,今天就日志管理方面做一些改善. 下了demo的网友可能会发现项目在启动时会有警告: ...

  5. 使用IntelliJ IDEA和Maven管理搭建+Web+Tomcat开发环境

    使用IntelliJ IDEA和Maven管理搭建+Web+Tomcat开发环境 前言:原来一直使用Eclipse,换工作后使用IDEA,初识IDEA发现,哇,它的快捷键可真多啊,但是一路用下来,觉得 ...

  6. 使用maven+eclipse搭建最简单的struts2的helloworld

    使用maven+eclipse搭建最简单的struts2的helloworld 一.web分层结构简介 1.web[细]粒度分层结构: 按细粒度分层可以分为以下6种: 1).表现层:html/css/ ...

  7. IDEA右侧 Maven oracle依赖包有红色波浪线

    1\下载 ojdbc14-10.2.0.4.0.jar http://www.java2s.com/Code/Jar/o/Downloadojdbc14102040jar.htm 2.将ojdbc14 ...

  8. window Maven私服搭建——nexus

    注:本文来源于 <window   Maven私服搭建--nexus> Maven私服搭建--nexus 1.下载nexus https://www.sonatype.com/downlo ...

  9. Linux安装配置maven以及搭建nexus私服(编写启动脚本)

    2011年07月12日16:32  下面介绍在Linux操作系统下安装配置maven和搭建nexus私服. 一.安装前的准备 下载 jdk http://www.oracle.com/technetw ...

随机推荐

  1. C++复制初始化的限制

    相比于直接初始化,复制初始化有更加严格的限制. 1:在复制初始化时,不能使用声明为explicit的构造函数进行的隐式转换.而直接初始化则是允许的: struct Exp { explicit Exp ...

  2. [iOS开发系列]根据Debug和Release状态的变化来屏蔽日志输出

    今天在这里分享一个很实用的小技巧. 我们平时在开发应用的时候,经常会用到NSLog来调试我们的程序,而随着项目越来越大,这些用于调试的日志输出就会变得很难管理. 我们在发布正式版的时候一定要屏蔽掉所有 ...

  3. 利用IDEA构建springboot应用-配置文件

    application.properties配置文件(不建议采用这种配置) 配置文件采用:application.yml文件会更简便,要带空格 属性配置与类中取值 添加bean属性配置到一个类里面,采 ...

  4. Warning!程序员们小心被技术绑架

    通常我们说程序员需要在某个技术方向上积累到一定的厚度,要能够运用技术有效地解决实际问题.可是当程序员在某一项技术上浸淫时间长了之后,却经常会出现另外的问题,那就是:看待问题时受限于自身的技术积累. 我 ...

  5. oracle函数 VARIANCE([distinct|all]x)

    [功能]统计数据表选中行x列的方差. [参数]all表示对所有的值求方差,distinct只对不同的值求方差,默认为all 如果有参数distinct或all,需有空格与x(列)隔开. [参数]x,只 ...

  6. QT 开发ros gui过程中遇到:error: catkin_package() include dir 'include' does not exist relative to '/home/jun/catkin_ws/src/qt_ros_test' /opt/ros/kinetic/share/catkin/cmake/catkin_package.cmake:102 (_catkin_p

    这是因为在ros工作空间的包中没有include文件夹造成的,所以在该路径下创建include的文件夹,问题就解决了.

  7. js+canvas 一只一担小游戏

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  8. 5-2 正则表达式及其re模块

    一 正则表达式 在线测试工具 http://tool.chinaz.com/regex/ 字符 量词 贪婪匹配 贪婪匹配:在满足匹配时,匹配尽可能长的字符串,默认情况下,采用贪婪匹配,<.*&g ...

  9. 逆序对(POJ2299 Ultra-QuickSort)

    #include<bits/stdc++.h> using namespace std; int n; ],b[],ans;//a为待排序数组,b为临时数组,ans为逆序对数 void m ...

  10. CSS引入的方式有哪些? link和@import的区别是?

    CSS引入的方式包括内联 内嵌 外链 导入 link和@import的区别是 : ①link属于XHTML标签,除了加载CSS外,还能 用于定义RSS, 定义rel连接属性等作用:而@import是C ...