首页
关于
留言
统计
友链
壁纸
影视
留言找电影
Search
1
java jdk17版本使用cglib报错问题解决
359 阅读
2
在Java中修复json数据,json格式不正确,如何在Java中修复不正确的json
158 阅读
3
Java实现双链表插入排序~渡星河全网首发
117 阅读
4
npm nvm 淘宝镜像最新可用
103 阅读
5
Java打印某年某月的日历~不调用函数
88 阅读
代码笔记
Java
css
Javascript
数据库
安卓开发
Java 功能实例
Java 封装
我的日常
影音分享
文案
恋爱问答
资源分享
电脑游戏
实用APP
登录
/
注册
Search
标签搜索
java
java作业
恋爱
动漫
3A大作
独行月球
电影分享
总之就是非常可爱
JavaScript
office
破解
mysql
vue
java打包
跨域
tomcat解决乱码
bug解决
tomcat
vscode
渡星河
累计撰写
94
篇文章
累计收到
30
条评论
首页
栏目
代码笔记
Java
css
Javascript
数据库
安卓开发
Java 功能实例
Java 封装
我的日常
影音分享
文案
恋爱问答
资源分享
电脑游戏
实用APP
页面
关于
留言
统计
友链
壁纸
影视
留言找电影
搜索到
81
篇与
的结果
2023-03-24
mybatis-plus代码生成使用(springboot中使用版本)
代码在test中调用,在test文件夹里面创建类package com.pms.pms; import com.baomidou.mybatisplus.annotation.DbType; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.generator.AutoGenerator; import com.baomidou.mybatisplus.generator.config.DataSourceConfig; import com.baomidou.mybatisplus.generator.config.GlobalConfig; import com.baomidou.mybatisplus.generator.config.PackageConfig; import com.baomidou.mybatisplus.generator.config.StrategyConfig; import com.baomidou.mybatisplus.generator.config.rules.DateType; import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy; import org.junit.jupiter.api.Test; public class CodeTest { @Test public void run() { // 1、创建代码生成器对象 AutoGenerator mpg = new AutoGenerator(); // 2、全局配置 GlobalConfig gc = new GlobalConfig(); String projectPath = System.getProperty("user.dir"); //指定生成的代码和包存放的地方 gc.setOutputDir("E:\\SSM\\pms" + "/src/main/java"); gc.setAuthor("duGalaxy");//作者 gc.setOpen(false); //生成后是否打开资源管理器 gc.setFileOverride(false); // 不覆盖之前的 gc.setServiceName("%sService");//生成的业务层接口不需要前面有一个 gc.setIdType(IdType.ASSIGN_ID);//主键策略的设置(字符串类型的数字) gc.setDateType(DateType.ONLY_DATE);//设置日期类型 gc.setSwagger2(true);//是否开启swagger配置 mpg.setGlobalConfig(gc); // 3、数据源配置 DataSourceConfig dsc = new DataSourceConfig(); dsc.setUrl("jdbc:mysql://localhost:3306/pms?serverTimezone=GMT%2B8"); dsc.setDriverName("com.mysql.cj.jdbc.Driver"); dsc.setUsername("root"); dsc.setPassword("500423"); dsc.setDbType(DbType.MYSQL); mpg.setDataSource(dsc); // 4、包配置 PackageConfig pc = new PackageConfig(); pc.setParent("cn.muau.pms");//指定父包名称 // pc.setModuleName("uservice"); //指定模块名称(在分布式的项目中才会指定) pc.setController("controller");//控制层报名 pc.setEntity("entity");//实体类包名 pc.setService("service");//业务层包名 pc.setMapper("mapper");//dao层包名 mpg.setPackageInfo(pc); // 5、策略配置 StrategyConfig strategy = new StrategyConfig(); strategy.setInclude("t_developer");//数表的名称(就是指定要为哪一张数据表生成代码和包) //数据表映射到实体类的命名策略,比如数据表为t_emp--->tEmp strategy.setNaming(NamingStrategy.underline_to_camel); //生成实体类的时候去掉表的前缀(比如表名为t_emp_info--->empInfo) // strategy.setTablePrefix(pc.getModuleName() + "_"); strategy.setTablePrefix("t_"); //生成实体类的时候的字段的命名策略(遵循驼峰原则比如 e_name--->eName) strategy.setColumnNaming(NamingStrategy.underline_to_camel); strategy.setEntityLombokModel(true);//开启lombok插件的使用 strategy.setRestControllerStyle(true);//restful风格的api配置 strategy.setControllerMappingHyphenStyle(true);// url中驼峰转字符 mpg.setStrategy(strategy); // 6、执行 mpg.execute(); } } pom文件<dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-api</artifactId> <version>2.21.0</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> <version>2.15.2</version> </dependency> <dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-core</artifactId> <version>2.21.0</version> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <scope>runtime</scope> </dependency> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <optional>true</optional> </dependency> <dependency> <groupId>com.alibaba</groupId> <artifactId>fastjson</artifactId> <version>1.2.83</version> </dependency> <!-- mybatis-plus依賴 --> <dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-boot-starter</artifactId> <version>3.4.2</version> </dependency> <dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-generator</artifactId> <version>3.4.1</version> </dependency> <dependency> <groupId>org.apache.velocity</groupId> <artifactId>velocity-engine-core</artifactId> <version>2.0</version> </dependency> <dependency> <groupId>com.alibaba</groupId> <artifactId>druid</artifactId> <version>1.2.8</version> </dependency> <dependency> <groupId>cn.hutool</groupId> <artifactId>hutool-all</artifactId> <version>5.7.17</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-mail</artifactId> </dependency> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> <version>3.12.0</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> <scope>provided</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <scope>provided</scope> </dependency> </dependencies> <dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-dependencies</artifactId> <version>${spring-boot.version}</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement>
2023年03月24日
18 阅读
0 评论
0 点赞
2023-03-15
ASCII艺术 项目启动打印好看的logo
皮卡丘 ▐▒▒░▄ ▒▒▒▒▒▒▒▒▄ ▐▒▒▒▒▒▒▒▒▒▒▒▄ ▄▄▒▒ ▒▒▒▒▒▒▒▒▒▒▒▒▒▒░▄ ▄▄▒▒▒▒▒▒▒▒ ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▄ ▄▒▒▒▒▒▒▒▒▒▒▒▒▒▌ ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▄ ▄▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ ▄░▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒░ ▐▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▄ ▄▄▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▄▄▄▄▄░▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒░▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ ▀▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▀ ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ ▀▒▒▒░▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▀ ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒░▒▒▒▒▀ ▄▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒░ ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ ▒▒▒▒▒▒▒▒▒▒░▄▄▄ ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒░▄▄▄ ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ ▒▒▒▒▒▒▒▒▒▒▒ ▀█▀ ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒░▐██▀ ▒▒▒▒▒▒▒▒▒▒▒▒▒▒░ ▒▒▒▒▒▒▒▒▒▒▒▒ ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒░ ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ ▐▒▒▒▒▒▒▒▒▒▒▒▒▒▄ ▄▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▄ ▄▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▀▀▀▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ ▐▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▄▄ ▄▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ ▒▒░░░░░░░░▐▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒░░░░░░░░░▒▒▒▒▒▒▒▒ ▐▒░░░░░░░░░░░▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒░░░░░░░░░░░░▐▒▒▒▒▒▒ ▒▒░░░░░░░░░░░▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▀░░░░▄░░░▀▒▒▒▒▒▒▒▒▒▒▒▒▒▒░░░░░░░░░░░░▐▒▒▒▒▒▒▒ ▐▒▒░░░░░░░▄░▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ ▒▒▒▒▒▒▒▒▒▒ ▒▒▒▒▒▒▒▒▒▒▒▒▒▒░░░░░░░░░░░▒▒▒▒▒▒▒▒ ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ ▒▒▒▒▒▒▒▒▒▒▒░▐▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒░░░░░▒▒▒▒▒▒▒▒▒▒▒▒ ▐▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ ▒▒▒▒▒▒▒▒▒▒░▐▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▄░▀▒▒▒▒▀░▄▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ ▐▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ 孙悟空 ,111, 0110 1110 ,111, 0111 1110 ,111, 0111 , 0110 000, 1 ,111 000000, 1 0111 100000000, 0 0110 00000000001 ,0 ,111 000000000000, 0 111, ,0000000000000, 00 0111 00000000000000 00 1110 10000000000000000, 00000000000000100 111, ,0000000000000000000,,0000000000000000 ,0111 00000000000000000000000000000000000 1110 00000000000000000000000000000000000000 ,111, 10000000000000000000000000000000000000 0111 ,000000000000000000000000000000000000 1110 ,000000000000000000000000000000000000 00 1111 ,000000000000000000000000000000000000000001111100000 ,100000000000000000000000000000000000000000001110000001 100000000000000000000000000000000000000000000000000001100000 000000000000000000000000000,,000000000010000000000000000011101 10000000000000000000,,,,0000000,1,1000000100000000000110000, 100000000000001,0,,00000, 1,,100000,10000000000011100000, 1000010000,,00000,,,1,,,1000,00000000000000111000, 01000 ,0010,, 000 ,,,,,,10000,0,001,000000101110 100000000000,,,,,, ,,0,,,,10 1,1,,,0010000 1110 010000,,1,, ,11 01 ,,1,10000000 1011 01000,1,,, ,,,,,,1 ,,,1,001,, 0110 00001, 1,,,,,,,,,,,,,,,,,,,,, 1110 1000000000 ,,,,,,,111,,,,,,,, 1110 000000,100011 , , ,,,,,,, ,, 0111 000001011111,,111,11,,,,,,,,,111111111, 11101, 0000,110100111111,11,,,,,,,,,11111101 ,,,011001 0001,11,,,,0111111111,,,,1,,,1111111 100,,,100110 ,0010,,,,,,,11111111,11,, ,,11101111,,,,,000,,,010111 00,,,,,,,,,0101111111,01,,,11111100,,,,,0011,,111110 0,,,,,,,,,,,001111111110,011,1,,,110,,,,,,000,011101 ,,,,,,,,,,,1,010111111111110,0,000 ,10,,,,,,,01 0110 1,,,,,,,1,1010111111101111110111 11011, 1110 ,,,,,,,,10100101111111011111111111011, 111, ,,,,,,10001,,01000011110101111110,,0, 0110 00000011,,,,1000000000000000000000, 1110 0001,,,,,,,1111110111100100011111, 111, 0,,,,,,1011011111110001100111111 0110 1,,001111111011100011100011110 1110 ,1101111111111111000101100011110 ,111, 11110111111111110001101100001111, 0111 ,000111111111111000010111100011110 1110 11011111111111100000011111000111110 ,111 ,11011111111111111101111001000011111, 0111 ,1001111111111111111111101010001111111 0110 0111110011111111110, 0110110111111011, ,111 0111110001111111110 011111111111101, 0111 ,01000111111110101, ,0111101001111 0110 01010011111111011, 0010111001,1 ,110 11100011010100, 10000, 100000, 111, 1000001011110 ,1100000000000, 0110 00 00 1110 0000000000 ,111, 100000000, ,1001, 奥特曼 .'. .0llo. .O..,d: dc .:x' .k:;. ..xc. .cx:'';. ',lol:' .lx:''''', .;''::o' ;o:''''''',. .;;'', co. cc .,'''''', .,'';. ;k. ,O. .,''''';. .,'''' ;x. 'k;, .''''''; .;,'', .cO. .x:''; '''''':. ':''' .:cxc o; ',',. .,''';. .:,;. . .l: cc. ...'. .''' .; .:l ld .. ; ..'',cx; dc... ....... ' ,'....cO ol:;. :......','' . ,,.....0: lol:.,;........': ..,'...;:O. ;ol.. .',....,,, . .... lc ,l; ..... . 'x ;k: . O, .cc::l. .. .. .';. lOdlcc. co. .dd:c .''.' .c,,dk: .d; 'xx':oc:,''kd:''.....,lOko. d' .d0koxx. ...oOOkkkxxlolxkd:;:;;;:cxko, '0kx..l. . .lo0kdxo;;dxkdc. ..,okOx; lOl ::''cckOO0kdoldxkxxo,. .:. ,dl;'cx 'K; .:xd:c0:dxxxddxxxl;. 'kOKx'' 'k .:::::,. .0c ,dxxxl, 'o0d,,::,,:. o, .Ox: co. ':dxd0k,... .oc: .k,.:o' .,:oxxxxc.lo::;::',, 'oO, ,xdlxxxxxx:. .O l0kk' lxxxxxxx' .0l .kOxxxd, ,OOOkkk; .dx0. .Okxxxoclo':l,..':O. ;oxxxOx dcxl' ;k. 'x:dooxxl.l: ;d . lc .0. .:: d. .co;.. .k. lc 'd .O. .. ...lx x' .,,. ,o. .dd:,;clol::,. ,k. . .O. ',.. ,l: ;k. .;:c:;;, 蝙蝠 _ _ _==/ i i \== /XX/ |\___/| \XX\ /XXXX\ |XXXXX| /XXXX\ |XXXXXX\_ _XXXXXXX_ _/XXXXXX| XXXXXXXXXXXxxxxxxxXXXXXXXXXXXxxxxxxxXXXXXXXXXXX |XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX| XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX |XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX| XXXXXX/^^^^"\XXXXXXXXXXXXXXXXXXXXX/^^^^^\XXXXXX |XXX| \XXX/^^\XXXXX/^^\XXX/ |XXX| \XX\ \X/ \XXX/ \X/ /XX/ "\ " \X/ " /" ! -Zach Bolinger- 忘记叫什么了 ::## ##:: ::::::## ##:::::: ::::::## ## : ## ##:::::: ::::::::## ##::##::## ##:::::::: ::::::::## ####::##::#### ##:::::::: :::::::::: ####::::::::::::::#### :::::::::: :::::::::: ##::::::::::::::::::::::## :::::::::: ::::::::::##@@::::::::::::::::::::::@@##:::::::::: ::::::::##@@##@@::::::::::::::::::@@##@@##:::::::: ::::::##@@######@@::::::::::::::@@######@@##:::::: ##::##@@#### ##@@::::::::::@@## ####@@##::## ::##@@########@@::::::::::@@########@@##:: ####@@## ####@@::######::@@#### ##@@#### ##::@@####@@::##########::@@####@@::## ##::::@@@@::::::######::::::@@@@::::## :::::::::::::::::::::::::::::::::: ::@@@@@@@@@@@@@@@@@@@@@@@@@@:: ##::@@@@@@::## ##::::##@@##::::## ######::##@@##::###### ##::::::####@@####::::::## ######::##@@@@@@##::###### ######::##@@@@@@##::###### ##::::::##########::::::## ###### ###### 电脑 _______________________________________ |,---"-----------------------------"---,| ||___ 16 bit.................... || ||====\ :HHHHHHHHHHHHHHHHHHHHHHHHHHH || ||=====):H c> pb# H || ||====/ :H H || ||""" :H H || ||PORTFO:H H || || :HHHHHHHHHHHHHHHHHHHHHHHHHHH || ||_____,_________________________,_____|| |)_____)-----.| /I\ATARI |.------(_____(| //"""""""|_____|=----------=|______|"""""""\ // _| _| _| _| _| _| _| _| _| _| _| _| _| _| \ // ___| _| _| _| _| _| _| _| _| _| _| _| | | \ |/ ___| _| _| _| _| _| _| _| _| _| _| _| ______| \ / __| _| _| _| _| _| _| _| _| _| _| _| _| _| ___| \ / _| _| _| _| ________________________| _| _| _| _| \ |------"--------------------------------------"-------| `-----------------------------------------------------' 女生I DIDN'T LISTEN TO MY MOTHER ABOUT CROSSING MY EYES SO THEY STUCK THIS WAY HOLY GOD I NEED TOOL \ .::::::`.::::::::::.. \ .''``````.::::::::::::::::: \ .:',ere$ze c ::::::::::::::::::: \ ,'` e$$$$$$$-K eeeu...`````::::::::: .zd>^leeu^R$%:FJ$$$$$$$$$$e.. ``:::::: .ed$$$$4$$$$$P-u@" ""?????R$$$$$$$hc. ``::: .e$$F"..: P??7loF .:::::::::::.."""?R$$$e. `:. zF".:::::::`"""'.:::::::::::::::::::::.`"?$$e.` .::::::::::::':::::::::::::::::::::::::::::.`"=. .:::::::::::::` `:::::::::::::::::::::::::::::::.. .:::::::::::::` ud$ec. ``:::::::::::::::::::::::::::::. .:::::::::::`` .zd$$$$$$$ec.. ```:::::::::::::::::::::::::: .:::::::::::` "??$$$$$$$$$$$P ``:::::::::::::::::::::: ::::::::::` .. $$*. ^$$$$$$$$$$ .e$**"" =e=.. ``::::::::::::::::. ::::::::: :::. . ^ $$P$$$$$$$$$$F .'$$$N4$$L'::. `::::::::::::::: `::::::` :::::: $ '$$4$$$$$$$$% - : $$$F$$$$u`::::::. `:::::::::::. :::::: :::::: .^m.-.e.$'$$$$$$$P. -)z$?Cd$$$$$u `:::::::. `::::::::: `::::::::::: J$buFh52d4$$$$$$$LcccccCz$$$$$$$$": `::::::::..::::::::: `::::::::: $$$$$$$$PJ$$$$$$$$$$$$$$$$$$$$$F.d$$. `::::::::::::::::` `:::::: ?$$$$$$$F$$$$$$$$$$$$$$$$$$$$P x$$$$$$L `:::::::::::::: ``:: dN ?$$$$$$N2$$?3$$$$$$$$$$$$$$P dP\$$$$$$$u `:::::::::::: `:'" $.`R$$P???$$P??????"$$$$$$$$ 9".d$$$$$$$$b.`:::::::::: :: R$$. ?$$r `..;; . $$$$$$$F"'$'$J?$$$$$$$f :::::::: `:.^""""""."?$`niiiodfu$$$$$F"z$$ ^""~""""`..:::: :::::: `::::::::::`?beCCbe$$$$""cd$$$$i .`::::::::::::. `:::` ``:::::::::`?$$$P"',cd$$$$$$$$r?k :::::::::::`.:::` ```::::::::: 4$$$$$$$$$$$$$"d$ ``::::::::::::` ``::: . $$$$$$$$$$$$fJ$F4$e.``:::::::` dR `$$$$$$$$$$"x$$ d$$$$eu,.``` .e$ $E b?$$$$$$$".d$$ d$$$$$$$$$$$e.. ..ee$$$$$ $$k`$$$$$$".d$$".$$$$$$$$$$$$$$$$$$hec. .ze$$$$$$$$$$$b"$$heeeeeud$R" e$$$$$$$$$$$$$$$$$$$$$$$$$e. z$$$$$$$$$$$$$$$$$$h`?c""""J$R z$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ .ee$$$$$$$$$$$$$$$$$$$$$$hc"xJ>=".zd$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ .d$$$$$$$$$$$$$$$$$$$$$$$$$$$$he$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$房子Art by Glory Moon )\ O_._._._A_._._._O /( \`--.___,'=================`.___,--'/ \`--._.__ __._,--'/ \ ,. l`~~~~~~~~~~~~~~~'l ,. / __ \||(_)!_!_!_.-._!_!_!(_)||/ __ \\`-.__ ||_|____!!_|;|_!!____|_|| __,-'// \\ `==---='-----------'='-----------`=---==' // | `--. ,--' | \ ,.`~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~',. / \|| ____,-------._,-------._,-------.____ ||/ ||\|___!`======="!`======="!`======="!___|/|| || |---||--------||-| | |-!!--------||---| || __O_____O_ll_lO_____O_____O|| |'|'| ||O_____O_____Ol_ll_O_____O__ o H o o H o o H o o H o o |-----------| o o H o o H o o H o o H o ___H_____H_____H_____H____O =========== O____H_____H_____H_____H___ /|=============|\ ()______()______()______() '==== +-+ ====' ()______()______()______() ||{_}{_}||{_}{_}||{_}{_}/| ===== |_| ===== |\{_}{_}||{_}{_}||{_}{_}|| || || || / |==== s( )s ====| \ || || || ======================() ================= ()====================== ----------------------/| ------------------- |\---------------------- / |---------------------| \ -'--'--' () '---------------------' () /| ------------------------- |\ --'--'--' --'--' / |---------------------------| \ '--' () |___________________________| () '--'- --'- /| _______________________________ |\ --' gpyy / |__________________________________| \
2023年03月15日
18 阅读
1 评论
2 点赞
2023-03-15
ssm框架写一个登录例子
我使用servlet写一个登录ChatGPT以下是使用servlet写一个简单的登录示例:创建一个名为LoginServlet的servlet类,继承HttpServlet类。在doGet()和doPost()方法中编写登录逻辑。在web.xml文件中配置servlet。示例代码如下:LoginServlet.javaimport java.io.IOException; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @WebServlet("/LoginServlet") public class LoginServlet extends HttpServlet { private static final long serialVersionUID = 1L; protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doPost(request, response); } protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String username = request.getParameter("username"); String password = request.getParameter("password"); if (username.equals("admin") && password.equals("admin123")) { response.sendRedirect("success.jsp"); } else { response.sendRedirect("error.jsp"); } } }web.xml<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"> <display-name>LoginServlet</display-name> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> <servlet> <servlet-name>LoginServlet</servlet-name> <servlet-class>LoginServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>LoginServlet</servlet-name> <url-pattern>/LoginServlet</url-pattern> </servlet-mapping> </web-app>index.jsp<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Login</title> </head> <body> <form action="LoginServlet" method="post"> <label>Username:</label> <input type="text" name="username"><br> <label>Password:</label> <input type="password" name="password"><br> <input type="submit" value="Login"> </form> </body> </html>success.jsp<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Success</title> </head> <body> <h1>Login Successful</h1> </body> </html>error.jsp<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Error</title> </head> <body> <h1>Login Failed</h1> </body> </html>在浏览器中访问http://localhost:8080/LoginServlet/index.jsp,输入正确的用户名和密码,将会跳转到success.jsp页面,否则跳转到error.jsp页面。我ssm框架写一个登录例子ChatGPT以下是使用SSM框架写一个简单登录的例子:创建一个名为User的实体类,包含用户名和密码属性。创建一个名为UserMapper的mapper接口,定义查询用户的方法。创建一个名为UserMapper.xml的mapper文件,编写查询用户的SQL语句。创建一个名为UserService的service接口,定义检查用户登录的方法。创建一个名为UserServiceImpl的service实现类,实现UserService接口。创建一个名为UserController的controller类,处理用户登录请求。在web.xml文件中配置DispatcherServlet。创建一个名为login.jsp的登录页面。示例代码如下:User.javapublic class User { private String username; private String password; // getters and setters }UserMapper.javapublic interface UserMapper { User getUserByUsername(String username); }UserMapper.xml<mapper namespace="com.example.mapper.UserMapper"> <select id="getUserByUsername" resultType="com.example.model.User"> select * from user where username=#{username} </select> </mapper>UserService.javapublic interface UserService { boolean checkUser(String username, String password); }UserServiceImpl.java@Service public class UserServiceImpl implements UserService { @Autowired private UserMapper userMapper; @Override public boolean checkUser(String username, String password) { User user = userMapper.getUserByUsername(username); if (user != null && user.getPassword().equals(password)) { return true; } return false; } }UserController.java@Controller public class UserController { @Autowired private UserService userService; @RequestMapping("/login") public String login(HttpServletRequest request) { String username = request.getParameter("username"); String password = request.getParameter("password"); if (userService.checkUser(username, password)) { return "success"; } else { return "error"; } } }web.xml<web-app> <display-name>SSM Login Example</display-name> <!--配置DispatcherServlet--> <servlet> <servlet-name>dispatcherServlet</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/dispatcherServlet-servlet.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>dispatcherServlet</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> </web-app>dispatcherServlet-servlet.xml<beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd"> <context:component-scan base-package="com.example.controller" /> <context:component-scan base-package="com.example.service" /> <context:component-scan base-package="com.example.mapper" /> <mvc:annotation-driven /> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"> <property name="driverClassName" value="com.mysql.jdbc.Driver" /> <property name="url" value="jdbc:mysql://localhost:3306/test?useSSL=false" /> <property name="username" value="root" /> <property name="password" value="password" /> </bean> <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <property name="configLocation" value="classpath:mybatis-config.xml" /> </bean> <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> <property name="basePackage" value="com.example.mapper" /> </bean> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/views/" /> <property name="suffix" value=".jsp" /> </bean> </beans>login.jsp<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Login</title> </head> <body> <form action="login" method="post"> <label>Username:</label> <input type="text" name="username"><br> <label>Password:</label> <input type="password" name="password"><br> <input type="submit" value="Login"> </form> </body> </html>success.jsp<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Success</title> </head> <body> <h1>Login Successful</h1> </body> </html>error.jsp<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Error</title> </head> <body> <h1>Login Failed</h1> </body> </html>在浏览器中访问http://localhost:8080/login.jsp,输入正确的用户名和密码,将会跳转到success.jsp页面,否则跳转到error.jsp页面。
2023年03月15日
15 阅读
0 评论
0 点赞
2023-03-14
java 中cron表达式怎么用
Cron表达式是一种用于指定定时任务执行时间的格式,通常用于Java中的定时任务框架,如Quartz和Spring的@Scheduled注解。Cron表达式由6个字段组成,分别表示秒、分、时、日、月、周几,每个字段可以使用通配符、数字、范围、列表和特殊字符等进行指定。下面是一个Cron表达式的示例:0 0 12 * * ?这个表达式表示每天中午12点执行任务。下面是Cron表达式中各个字段的含义:秒(0-59)分钟(0-59)小时(0-23)日(1-31)月(1-12或JAN-DEC)周几(1-7或SUN-SAT)在Java中,可以使用Quartz或Spring的@Scheduled注解来指定定时任务的执行时间。下面是一个使用@Scheduled注解的示例:import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; @Component public class MyTask { @Scheduled(cron = "0 0 12 * * ?") public void run() { // 执行任务 } } *1.cron="\* * \* * \* ?": 表示每一年中的每秒执行一次* *2.cron="\* * \* 1 \* ?":* *表示每一年每月的1号的每一秒都执行一次任务* *3.cron="0 0 0 1 \* ?":表示每一年的每月的一号的**0时0分0秒执行任务* *4.cron="0 0 3 \* * ?":表示每一年的每月每日凌晨**3点0分0秒执行任务* *5.cron="0 0 3 1 \* ?":表示每一年的每月一号凌晨**3点0分0秒执行任务 这个示例中,使用@Scheduled注解指定了定时任务的执行时间为每天中午12点。
2023年03月14日
6 阅读
0 评论
1 点赞
2023-03-13
SSM搭建模板,包含web.xml和pom.xml
重复的东西就没有必要写多遍了web.xml<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd" version="4.0"> <!-- 注册springmvc--> <servlet> <servlet-name>myweb</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:dispatcherServlet.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>myweb</servlet-name> <url-pattern>/*</url-pattern> </servlet-mapping> <!--注册spring监听器--> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:applicationContext.xml</param-value> </context-param> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <!-- 注册字符去过滤器--> <filter> <filter-name>characterEncodingFilter</filter-name> <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> <init-param> <param-name>encoding</param-name> <param-value>utf-8</param-value> </init-param> <init-param> <param-name>forceRequestEncoding</param-name> <param-value>true</param-value> </init-param> <init-param> <param-name>forceResponseEncoding</param-name> <param-value>true</param-value> </init-param> </filter> <filter-mapping> <filter-name>characterEncodingFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> </web-app> pom.xml<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 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>org.example</groupId> <artifactId>SSM-Work</artifactId> <packaging>war</packaging> <version>1.0-SNAPSHOT</version> <name>SSM-Work Maven Webapp</name> <url>http://maven.apache.org</url> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <encoding>UTF-8</encoding> <java.version>11</java.version> <maven.compiler.source>11</maven.compiler.source> <maven.compiler.target>11</maven.compiler.target> </properties> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> <!-- https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api --> <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <version>4.0.1</version> <scope>provided</scope> </dependency> <!-- https://mvnrepository.com/artifact/javax.servlet.jsp/jsp-api --> <dependency> <groupId>javax.servlet.jsp</groupId> <artifactId>jsp-api</artifactId> <version>2.2</version> <scope>provided</scope> </dependency> <!-- https://mvnrepository.com/artifact/org.springframework/spring-webmvc --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>5.2.22.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-tx</artifactId> <version>5.2.22.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-jdbc</artifactId> <version>5.2.22.RELEASE</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-core</artifactId> <version>2.14.2</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> <version>2.14.2</version> </dependency> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis-spring</artifactId> <version>2.0.7</version> </dependency> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis</artifactId> <version>3.5.8</version> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>8.0.30</version> </dependency> <dependency> <groupId>com.alibaba</groupId> <artifactId>druid</artifactId> <version>1.2.10</version> </dependency> </dependencies> <build> <finalName>SSM-Work</finalName> </build> </project> springmvc配置文件,这里文件名为dispatcherServlet<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc https://www.springframework.org/schema/mvc/spring-mvc.xsd"> <!--springMvc配置文件--> <context:component-scan base-package="com.ssm.controller"/> <!-- 配置视图解析器--> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/jsp"/> <property name="suffix" value=".jsp"/> </bean> <!-- 注解驱动--> <!-- 响应ajax请求返回json--> <mvc:annotation-driven/> </beans> spring配置文件<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="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 https://www.springframework.org/schema/context/spring-context.xsd"> <!--spring配置文件--> <!-- 申明数据源链接数据库--> <context:property-placeholder location="classpath:conf/jdbc.properties"/> <!-- 声明数据源--> <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource" init-method="init" destroy-method="close"> <property name="url" value="${jdbc.url}"/> <property name="username" value="${jdbc.username}"/> <property name="password" value="${jdbc.password}"/> </bean> <!-- 创建mybatis的SqlsessionFactory--> <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource" ref="dataSource"/> <property name="configLocation" value="class:conf/mybatis.xml"/> </bean> <!-- 声明mybatis扫描器创建dao对象--> <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/> <property name="basePackage" value="com.ssm.dao"/> </bean> <!-- 声明service的注解@service所在包名的位置--> <context:component-scan base-package="com.ssm.service"/> <!-- 事务的配置注解配置,aspectj后面用到加--> </beans> mybatis.xml文件配置 <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd"> <configuration> <!-- 输出日志--> <!--<settings> <setting name="logImpl" value="STDOUT_LOGGING"/> </settings>--> <typeAliases> <!-- 实体类的包名,用于设置别名--> <package name="com.ssm.util"/> </typeAliases> <mappers> <!-- 一次加载所有的mapper.xml,文件名称和dao接口必须完全一样,使用name必须同一目录--> <package name="com.ssm.dao"/> </mappers> </configuration> {dotted startColor="#ff6c6c" endColor="#1989fa"/}{mtitle title="配置遇到的问题"/}如果遇到DAO层的mapper.xml无法被加载,可以使用在resources目录下新建一个mapper目录,一个xml对应一个类。需要修改applicationContext.xml<!-- 创建mybatis的SqlsessionFactory--> <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource" ref="dataSource"/> <property name="configLocation" value="classpath:mybatis.xml"/> <property name="mapperLocations" value="classpath:mapper/**/*.xml"/> </bean>多添加了一行扫描mapper目录下的所有xml还有一种方法在mybatis.xml配置文件中,不使用<mappers> <!– 一次加载所有的mapper.xml,文件名称和dao接口必须完全一样,使用name必须同一目录–> <package name="com.ssm.dao.UserDao"/> </mappers>先说一下,我们无法加载dao层下的所有xml就是这行代码没生效我们可以在这个配置文件中使用这种形式来指定 <mapper resource="com.ssm.dao.UserDao"/> </mappers> mapper.xml模板例子<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.ssm.dao.UserDao"> <!-- 在mybatis.xml文件中配置了别名所有可以不使用全限定--> <select id="selectUsers" resultType="User"> select id,name,age,password,power from users order by id desc </select> <insert id="insertUser"> insert into users(name,age,password,power) values(#{name},#{age},#{password},#{power}) </insert> <select id="login" resultType="User"> select name,password,power from users where name = #{name} </select> </mapper>
2023年03月13日
6 阅读
0 评论
1 点赞
1
...
6
7
8
...
17