Idea + maven (多个 module)
-
Spring + Spring MVC + MyBatis
-
WebSocket
-
Mybatis Generator
-
redis
-
shiro
-
二维码
-
HttpURLConnection
-
spring 定时器 Scheduled
-
ExtJS 集成失败
只有 web 勾选 Create from Archetype
, 并选择 maven-archetype-webapp
- 删除
ssmProject
的src
- 给
web
添加Java
- 样式比较适合做后端前台,风格统一,组件完备,功能强大
- 几乎不用写样式,直接调用组件就可以了
ExtJS的版本繁多,本文收集了ExtJS各个版本的下载链接,包括官网和非官网的,以及各种汉化版api,欢迎大家下载分享。
- ExtJS最新版下载链接:http://www.sencha.com/products/ExtJS/download/
- ExtJS 4.2.1 下载链接:http://cdn.sencha.com/ext/gpl/ext-4.2.1-gpl.zip
- ExtJS 4.0.7 下载链接:http://cdn.sencha.io/ext-4.0.7-gpl.zip
- ExtJS 3.4.0 下载链接:http://cdn.sencha.com/ext/gpl/ext-3.4.1.1-gpl.zip
- ExtJS 2.3.0 下载链接:http://dev.sencha.com/deploy/ext-2.3.0.zip
一般历史项目很多用的是2.2.x的版本,而且没有版权问题。(2.2.3相对稳定,但其实bug也不少)
3.x比起2.x改进很多,包括稳定性上的问题,但需要注意版权
4.x版本是一个飞跃式的版本,整个架构都更完善了,MVC,按需加载,plugin机制,components架构等都很不错。
4.0的时候侧重于底层架构,性能不行,后面的4.1和4.2的changelog都说大幅改进性能
- 解压
ext-6.2.0-gpl.zip
- 解压
SenchaCmd-6.2.2-osx-no_jre.app.zip
并安装 - 创建
ssmProject
工程sencha -sdk /Users/syc/Documents/ext-6.2.0 generate app ssmProject /Users/syc/Documents/workspace/ssmProject
export PATH=${PATH}:/Users/syc/bin/Sencha/Cmd/6.2.2.36
bogon:IdeaWorkspace syc$ sencha -sdk ext-6.2.0 generate app ssmProject ssmProject
Sencha Cmd v6.2.2.36
[WRN] the following remote package repository directories did not initialize properly :
[WRN] - /Users/syc/bin/Sencha/Cmd/repo/.sencha
[WRN] - /Users/syc/bin/Sencha/Cmd/repo/pkgs
[ERR] javax/xml/bind/DatatypeConverter
[ERR]
The application was last modified by an older version of Sencha Cmd (6.2.0.103).
Running "sencha package upgrade" may resolve the error described above.
在网上找前端框架的资料, 发现现在已经基本不用 ExtJS 了 我个人还是挺习惯 ExtJS 的, 但是此次未能成功集成😂😂😂
- 完善目录结构(controller / service / dao / model)
- 使用 maven 引入 ssm/数据库等各种 jar 包
log4j.properties
jdbc.properties
mapping/*.xml
spring-mvc.xml
spring-mybatis.xml
web.xml
war
将WEB工程以包的形式上传到服务器 发布模式,这是先打成war包,再发布war exploded
将WEB工程以当前文件夹的位置关系上传到服务器 直接把文件夹、jsp页面 、classes等等移到Tomcat 部署文件夹里面,进行加载部署。因此这种方式支持热部署,一般在开发的时候也是用这种方式。
spring4.0以后加入了对websocket技术的支持
参考 package com.syc.websocket
- 添加 jar 包
- 实现
HandshakeInterceptor
- 实现
WebSocketHandler
- 继承
WebMvcConfigurerAdapter
实现WebSocketConfigurer
- 添加 spring 配置
MyBatis Generator
(MBG) 是一个Mybatis的代码生成器,它可以帮助我们根据数据库中表的设计生成对应的 实体类
,xml Mapper
文件,接口以及帮助类(也就是我们可以借助该类来进行简单的CRUD操作),这样就避免了我们每使用到一张表的数据就需要手动去创建对应的类和xml文件,这就帮我们节约了大量的时间去开发和业务逻辑有关的功能,但是如果对联合查询和存储过程您仍然需要手写SQL和对象。
- maven 配置
<dependencies>
<dependency>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-core</artifactId>
<version>1.3.5</version>
</dependency>
...
</dependencies>
<build>
<finalName>ssmArtifact-web</finalName>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<plugin>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
<version>1.3.2</version>
<configuration>
<verbose>true</verbose>
<overwrite>true</overwrite>
</configuration>
</plugin>
...
</plugins>
</pluginManagement>
</build>
-
配置 generatorConfig.xml
-
运行
List<String> warnings = new ArrayList<String>();
boolean overwrite = true;
//指定 逆向工程配置文件
File configFile = new File(MybatisGenerator.class.getResource("/generatorConfig.xml").getFile());
ConfigurationParser cp = new ConfigurationParser(warnings);
Configuration config = null;
try {
config = cp.parseConfiguration(configFile);
} catch (IOException e) {
e.printStackTrace();
} catch (XMLParserException e) {
e.printStackTrace();
}
DefaultShellCallback callback = new DefaultShellCallback(overwrite);
MyBatisGenerator myBatisGenerator = null;
try {
myBatisGenerator = new MyBatisGenerator(config, callback, warnings);
} catch (InvalidConfigurationException e) {
e.printStackTrace();
}
try {
myBatisGenerator.generate(null);
} catch (SQLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
- 添加 maven 依赖
spring-data-redis
spring-redis实现jedis
redis客户端mybatis-ehcache
Ehcache实现,用于参考
- 添加
redis.properties
文件, 配置 Redis 参数 - 添加
spring-redis.xml
配置文件 - 在
web.xml
中contextConfigLocation
进行配置
- 配置 maven 依赖
- 配置
spring-shiro.xml
- 实现类
- 在
web.xml
配置DelegatingFilterProxy
- 配置 maven 依赖 (com.google.zxing)
- 参考
QRCodeController
类
参考使用 HttpURLConnection
的 com.syc.http.HttpUtil
工具类
请求方式
- 使用原生
HttpURLConnection
- 使用
HTTPClient
- spring 配置文件
beans
中添加属性xmlns:task="http://www.springframework.org/schema/task"
及xsi:schemaLocation
- spring 配置文件
<beans>
标记内添加
<context:component-scan base-package="com.syc.task" />
<task:executor id="executor" pool-size="5" />
<task:scheduler id="scheduler" pool-size="10" />
<task:annotation-driven executor="executor" scheduler="scheduler" mode="proxy"/>
-
实现了添加注解
@Component
@Scheduled
参考com.syc.task.MyTask
- fixedDelay
- cron
Idea + Maven 多 module 工程, module 间相互依赖的简单 Java Web Demo
- 基于Maven+SSM整合shiro+Redis实现后台管理项目 https://www.cnblogs.com/maixianyu8888/p/8302151.html
- ssm整合Redis https://cloud.tencent.com/developer/article/1019826
- Mybatis Generator自动生成 https://blog.csdn.net/niqinge/article/details/79280204
- 打包时mapper.xml文件打不进war包 https://www.cnblogs.com/ANCAN-RAY/p/7009258.html
- 二维码 https://blog.csdn.net/zgliang88/article/details/54617795
- http https://www.cnblogs.com/hhhshct/p/8523697.html