Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
license-spring-boot-starter
Overview
Overview
Details
Activity
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
黄营
license-spring-boot-starter
Commits
60560651
Commit
60560651
authored
Jan 12, 2024
by
hy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加LicenseProperties
parent
b3a26a6f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
2 deletions
+19
-2
LicenseAutoConfiguration.java
src/main/java/com/tbyf/license/LicenseAutoConfiguration.java
+4
-1
LicenseInstallationServlet.java
...ain/java/com/tbyf/license/LicenseInstallationServlet.java
+4
-1
LicenseProperties.java
src/main/java/com/tbyf/license/LicenseProperties.java
+11
-0
No files found.
src/main/java/com/tbyf/license/LicenseAutoConfiguration.java
View file @
60560651
...
...
@@ -3,6 +3,7 @@ package com.tbyf.license;
import
org.springframework.boot.autoconfigure.AutoConfiguration
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication
;
import
org.springframework.boot.autoconfigure.web.servlet.DispatcherServletAutoConfiguration
;
import
org.springframework.boot.context.properties.EnableConfigurationProperties
;
import
org.springframework.boot.web.servlet.FilterRegistrationBean
;
import
org.springframework.boot.web.servlet.ServletRegistrationBean
;
import
org.springframework.context.annotation.Bean
;
...
...
@@ -10,6 +11,7 @@ import org.springframework.core.Ordered;
import
javax.servlet.MultipartConfigElement
;
@EnableConfigurationProperties
(
LicenseProperties
.
class
)
@ConditionalOnWebApplication
(
type
=
ConditionalOnWebApplication
.
Type
.
SERVLET
)
@AutoConfiguration
(
after
=
{
DispatcherServletAutoConfiguration
.
class
})
public
class
LicenseAutoConfiguration
{
...
...
@@ -30,9 +32,10 @@ public class LicenseAutoConfiguration {
}
@Bean
public
ServletRegistrationBean
<
LicenseInstallationServlet
>
licenseServlet
()
{
public
ServletRegistrationBean
<
LicenseInstallationServlet
>
licenseServlet
(
LicenseProperties
licenseProperties
)
{
LicenseInstallationServlet
servlet
=
new
LicenseInstallationServlet
();
servlet
.
setLicenseManager
(
licenseManager
());
servlet
.
setProperties
(
licenseProperties
);
ServletRegistrationBean
<
LicenseInstallationServlet
>
registrationBean
=
new
ServletRegistrationBean
<>(
servlet
,
"/license/install"
);
registrationBean
.
setMultipartConfig
(
new
MultipartConfigElement
(
""
,
1024
*
1024
,
1024
*
1024
,
1024
*
1024
));
return
registrationBean
;
...
...
src/main/java/com/tbyf/license/LicenseInstallationServlet.java
View file @
60560651
...
...
@@ -24,12 +24,15 @@ public class LicenseInstallationServlet extends HttpServlet {
@Setter
private
LicenseManager
licenseManager
;
@Setter
private
LicenseProperties
properties
;
@Override
protected
void
doPost
(
HttpServletRequest
req
,
HttpServletResponse
resp
)
throws
ServletException
,
IOException
{
Part
filePart
=
req
.
getPart
(
"license"
);
String
fileName
=
filePart
.
getSubmittedFileName
();
try
(
InputStream
is
=
filePart
.
getInputStream
())
{
Path
dest
=
Paths
.
get
(
fileName
);
Path
dest
=
Paths
.
get
(
properties
.
getLocation
(),
fileName
).
toAbsolutePath
().
normalize
(
);
Files
.
copy
(
is
,
dest
,
StandardCopyOption
.
REPLACE_EXISTING
);
this
.
licenseManager
.
install
(
dest
.
toString
());
resp
.
setStatus
(
HttpStatus
.
OK
.
value
());
...
...
src/main/java/com/tbyf/license/LicenseProperties.java
0 → 100644
View file @
60560651
package
com
.
tbyf
.
license
;
import
lombok.Data
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
@Data
@ConfigurationProperties
(
prefix
=
"license"
)
public
class
LicenseProperties
{
private
String
location
=
"/hip/license"
;
}
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