Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
ioc_sixiang_license
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zengtianlai3
ioc_sixiang_license
Commits
ccb66224
Commit
ccb66224
authored
Jul 11, 2022
by
zengtianlai3
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
2.3.7 异常处理:finally代码块中抛出异常
parent
8ebd2e59
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
75 deletions
+20
-75
TcpServer.java
license/src/main/java/iot/sixiang/license/net/TcpServer.java
+8
-4
ResourceManager.java
...in/java/iot/sixiang/license/resource/ResourceManager.java
+12
-4
CodeGenerator.java
...src/main/java/iot/sixiang/license/util/CodeGenerator.java
+0
-67
No files found.
license/src/main/java/iot/sixiang/license/net/TcpServer.java
View file @
ccb66224
...
...
@@ -45,11 +45,15 @@ public class TcpServer {
f
.
channel
().
closeFuture
().
sync
();
}
catch
(
InterruptedException
e
)
{
// TODO Auto-generated catch block
log
.
error
(
"Tcp服务异常,端口:{}"
,
port
);
}
finally
{
log
.
error
(
"Tcp服务异常,端口:{}"
,
port
);
}
finally
{
log
.
debug
(
"Tcp服务,停止退出"
);
workerGroup
.
shutdownGracefully
();
bossGroup
.
shutdownGracefully
();
if
(
workerGroup
!=
null
)
{
workerGroup
.
shutdownGracefully
();
}
if
(
bossGroup
!=
null
)
{
bossGroup
.
shutdownGracefully
();
}
}
}
});
...
...
license/src/main/java/iot/sixiang/license/resource/ResourceManager.java
View file @
ccb66224
...
...
@@ -22,7 +22,7 @@ public class ResourceManager {
@Autowired
ResourceService
resourceService
;
public
void
downloadDeviceInfoExcle
(
HttpServletResponse
response
,
int
userId
)
throws
IOException
{
public
void
downloadDeviceInfoExcle
(
HttpServletResponse
response
,
int
userId
){
OutputStream
os
=
null
;
HSSFWorkbook
wb
=
null
;
try
{
...
...
@@ -113,13 +113,21 @@ public class ResourceManager {
}
wb
.
write
(
os
);
}
catch
(
IOException
e
)
{
log
.
error
(
"Excel表格信息下载异常,{}"
,
e
.
getMessage
());
log
.
error
(
"Excel表格信息下载异常,{}"
,
e
.
getMessage
());
}
finally
{
if
(
os
!=
null
)
{
os
.
close
();
try
{
os
.
close
();
}
catch
(
IOException
e
)
{
log
.
error
(
"Excel表格信息下载异常,{}"
,
e
.
getMessage
());
}
}
if
(
wb
!=
null
)
{
wb
.
close
();
try
{
wb
.
close
();
}
catch
(
IOException
e
)
{
log
.
error
(
"Excel表格信息下载异常,{}"
,
e
.
getMessage
());
}
}
}
}
...
...
license/src/main/java/iot/sixiang/license/util/CodeGenerator.java
deleted
100644 → 0
View file @
8ebd2e59
package
iot
.
sixiang
.
license
.
util
;
import
com.baomidou.mybatisplus.annotation.DbType
;
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.NamingStrategy
;
public
class
CodeGenerator
{
public
static
void
main
(
String
[]
args
)
{
// 1、创建代码生成器
AutoGenerator
mpg
=
new
AutoGenerator
();
// 2、全局配置
GlobalConfig
gc
=
new
GlobalConfig
();
// String projectPath = System.getProperty("user.dir");
gc
.
setOutputDir
(
"D:\\zengtianlai\\test2\\ioc_sixiang_license\\license"
+
"/src/main/java"
);
gc
.
setAuthor
(
"lai"
);
gc
.
setOpen
(
false
);
//生成后是否打开资源管理器
gc
.
setFileOverride
(
false
);
//重新生成时文件是否覆盖
gc
.
setServiceName
(
"%sService"
);
//去掉Service接口的首字母I
mpg
.
setGlobalConfig
(
gc
);
// 3、数据源配置
DataSourceConfig
dsc
=
new
DataSourceConfig
();
dsc
.
setUrl
(
"jdbc:mysql://localhost:3306/iot_license?serverTimezone=GMT%2B8"
);
dsc
.
setDriverName
(
"com.mysql.cj.jdbc.Driver"
);
dsc
.
setUsername
(
"root"
);
dsc
.
setPassword
(
"123456"
);
dsc
.
setDbType
(
DbType
.
MYSQL
);
mpg
.
setDataSource
(
dsc
);
// 4、包配置
PackageConfig
pc
=
new
PackageConfig
();
pc
.
setModuleName
(
"license"
);
//模块名
pc
.
setParent
(
"iot.sixiang"
);
pc
.
setController
(
"controller"
);
pc
.
setEntity
(
"entity"
);
pc
.
setService
(
"service"
);
pc
.
setMapper
(
"mapper"
);
mpg
.
setPackageInfo
(
pc
);
// 5、策略配置
StrategyConfig
strategy
=
new
StrategyConfig
();
strategy
.
setInclude
(
"sys_oper_log"
);
strategy
.
setNaming
(
NamingStrategy
.
underline_to_camel
);
//数据库表映射到实体的命名策略
strategy
.
setTablePrefix
(
pc
.
getModuleName
()
+
"_"
);
//生成实体时去掉表前缀
strategy
.
setColumnNaming
(
NamingStrategy
.
underline_to_camel
);
//数据库表字段映射到实体的命名策略
strategy
.
setEntityLombokModel
(
true
);
// lombok 模型 @Accessors(chain = true) setter链式操作
strategy
.
setRestControllerStyle
(
true
);
//restful api风格控制器
strategy
.
setControllerMappingHyphenStyle
(
true
);
//url中驼峰转连字符
mpg
.
setStrategy
(
strategy
);
// 6、执行
mpg
.
execute
();
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment