快速实现一个增删改查 maven layui-table----1.项目基本配置

数据库设计FinancingProduct

powerDesigner
在这里插入图片描述
在这里插入图片描述
sql:

drop table if exists FinancingProduct;

/*==============================================================*/
/* Table: FinancingProduct                                     */
/*==============================================================*/
create table FinancingProduct
(
   id                   varchar(50) not null comment '产品代码',
   risk                 int not null comment '风险评级',
   income               varchar(50) not null comment '预期收益',
   saleStarting         datetime not null comment '发售起始日',
   saleEnd              datetime not null comment '发售截止日
            ',
   end                  datetime comment '产品到期日',
   primary key (id)
);

alter table FinancingProduct comment '理财产品信息表';

功能实现:增删改查

maven pom导入依赖:maven update project

<dependencies>
		<dependency>
			<groupId>com.ossjk</groupId>
			<artifactId>ossjk-servlet-core</artifactId>
			<version>0.0.1-SNAPSHOT</version>
		</dependency>
		<!-- 引入web工程所需的依赖 -->
		<dependency>
			<groupId>javax.servlet</groupId>
			<artifactId>javax.servlet-api</artifactId>
			<version>3.1.0</version>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>javax.servlet.jsp</groupId>
			<artifactId>jsp-api</artifactId>
			<version>2.2</version>
			<scope>provided</scope>
		</dependency>
		<!-- 添加JSTL标签库 -->
		<dependency>
			<groupId>javax.servlet</groupId>
			<artifactId>jstl</artifactId>
			<version>1.2</version>
		</dependency>
		<dependency>
			<groupId>taglibs</groupId>
			<artifactId>standard</artifactId>
			<version>1.1.2</version>
		</dependency>
		<!-- junit -->
		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
			<version>4.12</version>
			<scope>test</scope>
		</dependency>
		<!-- 添加MySQL数据库驱动依赖包. -->
		<dependency>
			<groupId>mysql</groupId>
			<artifactId>mysql-connector-java</artifactId>
			<version>5.1.30</version>
		</dependency>
		<!-- druid 连接池 -->
		<dependency>
			<groupId>com.alibaba</groupId>
			<artifactId>druid</artifactId>
			<version>1.0.18</version>
		</dependency>
		<!--json start -->
		<dependency>
			<groupId>com.alibaba</groupId>
			<artifactId>fastjson</artifactId>
			<version>1.2.15</version>
		</dependency>
		<dependency>
			<groupId>commons-io</groupId>
			<artifactId>commons-io</artifactId>
			<version>2.0.1</version>
		</dependency>
		<!--json end -->
		<!-- joda-time -->
		<dependency>
			<groupId>joda-time</groupId>
			<artifactId>joda-time</artifactId>
			<version>2.5</version>
		</dependency>
		<!-- jwt start -->
		<dependency>
			<groupId>io.jsonwebtoken</groupId>
			<artifactId>jjwt</artifactId>
			<version>0.6.0</version>
		</dependency>
		<dependency>
			<groupId>commons-codec</groupId>
			<artifactId>commons-codec</artifactId>
			<version>1.9</version>
		</dependency>
		<dependency>
			<groupId>org.apache.commons</groupId>
			<artifactId>commons-lang3</artifactId>
			<version>3.8</version>
		</dependency>
		<!-- jwt end -->
		<!-- log4j -->
		<dependency>
			<groupId>log4j</groupId>
			<artifactId>log4j</artifactId>
			<version>1.2.17</version>
			<scope>compile</scope>
		</dependency>
		<!-- https://mvnrepository.com/artifact/junit/junit -->
		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
			<version>4.11</version>
			<scope>test</scope>
		</dependency>

	</dependencies>
	<build>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-compiler-plugin</artifactId>
				<configuration>
					<source>1.8</source>
					<target>1.8</target>
					<encoding>UTF-8</encoding>
				</configuration>
			</plugin>
		</plugins>
	</build>

添加web
在这里插入图片描述
在这里插入图片描述

添加程序集

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

创建dao,添加配置文件

在这里插入图片描述在这里插入图片描述在这里插入图片描述
配置文件:

datasource.url = jdbc:mysql://127.0.0.1:3306/financingproduct?useUnicode=true&characterEncoding=utf-8
datasource.username = root
datasource.password = 123456
datasource.driver-class-name=com.mysql.jdbc.Driver

datasource.druid.initialSize=1
datasource.druid.minIdle=10
datasource.druid.maxActive=20
datasource.druid.maxWait=60000
datasource.druid.timeBetweenEvictionRunsMillis=3600000
datasource.druid.minEvictableIdleTimeMillis=300000
datasource.druid.validationQuery=select 1
datasource.druid.testWhileIdle=true
datasource.druid.testOnBorrow=true
datasource.druid.poolPreparedStatements=false
datasource.druid.maxPoolPreparedStatementPerConnectionSize=20

运行pojo,getter,setter,tostring.
在这里插入图片描述
泛型:
在这里插入图片描述
创建一个测试页面
在这里插入图片描述

servlet:

package com.test.admin.serlvet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ossjk.core.base.servlet.BaseServlet;

@WebServlet("/admin/index.do")
public class FpServlet extends BaseServlet {

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		doPost(req, resp);
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		String method = getMethod(req);
		if ("toindex".equals(method)) {
			toindex(req, resp);
		}
	}

	protected void toindex(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		forward(req, resp, "/WEB-INF/page/index.jsp");
	}

}

遇到class not found。基本都是没有添加程序集到maven
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值