Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
maven-project-demo
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
计万成
maven-project-demo
Commits
a7418a5f
Commit
a7418a5f
authored
Sep 07, 2020
by
jwc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
目录结构初步提交,支持swagger,lombok,docker打包
parent
a229c44e
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
176 additions
and
33 deletions
+176
-33
README.md
README.md
+39
-1
pom.xml
pom.xml
+77
-32
src/main/java/cn/zingfin/demo/web/controller/HelloWorldController.java
.../cn/zingfin/demo/web/controller/HelloWorldController.java
+3
-0
src/main/resources/application-publish.yml
src/main/resources/application-publish.yml
+48
-0
src/main/resources/docker/Dockerfile
src/main/resources/docker/Dockerfile
+9
-0
No files found.
README.md
View file @
a7418a5f
# maven-project-demo 项目模板
# 支持swagger,lombok
# swagger
localhost:8080/doc.html
# lombok
@Data,@Slfj4 ...
# docker打包
Dockerfile 文件 /main/java/resources/docker
```
FROM centos-jdk8
ADD demo-0.0.1-SNAPSHOT.jar /opt/app/demo-0.0.1-SNAPSHOT.jar
ENV JAVA_HOME=/opt/jdk1.8.0_261
ENV CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
ENV PATH=$JAVA_HOME/bin:$PATH
ENTRYPOINT [ \
"java","-Djava.security.egd=file:/dev/./urandom", \
"-Duser.timezone=Asia/Shanghai", \
"-jar","/opt/app/demo-0.0.1-SNAPSHOT.jar"]
```
自行修改以上文件。。。
我们运行下面的命令构建镜像:
```
mvn clean
mvn package docker:bulid
```
构建成功后,我们通过下面的命令查看镜像:
```
docker images
```
启动镜像:
```
#c2dba352c3c1 为镜像ID
docker run -p 8080:8080 -t c2dba352c3c1
```
pom.xml
View file @
a7418a5f
...
...
@@ -2,15 +2,19 @@
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<modelVersion>
4.0.0
</modelVersion>
<parent>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-parent
</artifactId>
<version>
2.2.0.RELEASE
</version>
<relativePath/>
<!-- lookup parent from repository -->
</parent>
<groupId>
cn.zing
</groupId>
<artifactId>
maven-project-demo
</artifactId>
<packaging>
pom
</packaging>
<artifactId>
demo
</artifactId>
<version>
0.0.1-SNAPSHOT
</version>
<name>
demo
</name>
<description>
项目模版
</description>
<distributionManagement>
<repository>
<id>
releases
</id>
...
...
@@ -26,10 +30,10 @@
</distributionManagement>
<properties>
<java.version>
1.8
</java.version>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<project.reporting.outputEncoding>
UTF-8
</project.reporting.outputEncoding>
<spring-boot.version>
2.2.0.RELEASE
</spring-boot.version>
<java.version>
1.8
</java.version>
<docker.image.prefix>
demo
</docker.image.prefix>
</properties>
<dependencies>
...
...
@@ -38,12 +42,16 @@
<artifactId>
lombok
</artifactId>
<optional>
true
</optional>
</dependency>
<dependency>
<groupId>
cn.zing.starter
</groupId>
<artifactId>
web-common-spring-boot-starter
</artifactId>
<version>
0.0.1-SNAPSHOT
</version>
</dependency>
<!--web核心依赖-->
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-web
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-configuration-processor
</artifactId>
...
...
@@ -61,8 +69,12 @@
<artifactId>
springfox-swagger-ui
</artifactId>
<version>
2.9.2
</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.github.xiaoymin/swagger-bootstrap-ui-->
<dependency>
<groupId>
cn.zingfin
</groupId>
<artifactId>
common
</artifactId>
<version>
0.0.2-SNAPSHOT
</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.github.xiaoymin/swagger-bootstrap-ui-->
<dependency>
<groupId>
com.github.xiaoymin
</groupId>
<artifactId>
swagger-bootstrap-ui
</artifactId>
...
...
@@ -78,12 +90,18 @@
</exclusion>
</exclusions>
</dependency>
<!--mysql数据库驱动-->
<dependency>
<groupId>
mysql
</groupId>
<artifactId>
mysql-connector-java
</artifactId>
<scope>
runtime
</scope>
</dependency>
<!--mybatis-->
<dependency>
<groupId>
org.mybatis.spring.boot
</groupId>
<artifactId>
mybatis-spring-boot-starter
</artifactId>
<version>
2.1.0
</version>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-test
</artifactId>
...
...
@@ -101,48 +119,74 @@
<artifactId>
spring-boot-starter-data-redis
</artifactId>
</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>
<groupId>
com.aliyun
</groupId>
<artifactId>
aliyun-java-sdk-green
</artifactId>
<version>
3.6.1
</version>
</dependency>
<dependency>
<groupId>
com.alibaba
</groupId>
<artifactId>
fastjson
</artifactId>
<version>
1.2.51
</version>
</dependency>
<dependency>
<groupId>
com.aliyun.oss
</groupId>
<artifactId>
aliyun-sdk-oss
</artifactId>
<version>
2.8.3
</version>
</dependency>
<dependency>
<groupId>
com.aliyun
</groupId>
<artifactId>
aliyun-java-sdk-core
</artifactId>
<version>
4.5.0
</version>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-
compiler
-plugin
</artifactId>
<version>
3.
8.1
</version>
<artifactId>
maven-
resources
-plugin
</artifactId>
<version>
3.
0.2
</version>
<configuration>
<source>
1.8
</source>
<target>
1.8
</target>
<encoding>
UTF-8
</encoding>
<!-- 过滤后缀为pem、pfx的证书文件 -->
<nonFilteredFileExtensions>
<nonFilteredFileExtension>
pfx
</nonFilteredFileExtension>
</nonFilteredFileExtensions>
</configuration>
</plugin>
<plugin>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-maven-plugin
</artifactId>
<version>
2.3.0
.RELEASE
</version>
<version>
1.5.6
.RELEASE
</version>
<configuration>
<mainClass>
cn.zingfin.demo.DemoApplication
</mainClass>
<layout>
JAR
</layout>
</configuration>
<executions>
<execution>
<id>
repackage
</id>
<goals>
<goal>
repackage
</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>
com.spotify
</groupId>
<artifactId>
docker-maven-plugin
</artifactId>
<version>
1.2.0
</version>
<configuration>
<imageName>
${docker.image.prefix}/${project.artifactId}
</imageName>
<dockerDirectory>
src/main/resources/docker
</dockerDirectory>
<resources>
<resource>
<targetPath>
/
</targetPath>
<directory>
${project.build.directory}
</directory>
<include>
${project.build.finalName}.jar
</include>
</resource>
</resources>
</configuration>
</plugin>
</plugins>
<resources>
<resource>
...
...
@@ -153,15 +197,16 @@
<!-- 打包时排除文件,可自行添加test.yml -->
<exclude>
application.yml
</exclude>
<exclude>
application-dev.yml
</exclude>
<exclude>
application-publish.yml
</exclude>
<!-- <exclude>application-test.yml</exclude>-->
</excludes>
</resource>
<resource>
<directory>
src/main/resources
</directory>
<filtering>
true
</filtering>
<!-- 打包时所包含得文件
,当包含与排除文件冲突时已包含文件为准
-->
<!-- 打包时所包含得文件 -->
<includes>
<include>
application.yml
</include>
<include>
application-dev.yml
</include>
<include>
application-${env}.yml
</include>
</includes>
</resource>
...
...
src/main/java/cn/zingfin/demo/web/controller/HelloWorldController.java
View file @
a7418a5f
...
...
@@ -3,6 +3,7 @@ package cn.zingfin.demo.web.controller;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.web.bind.annotation.*
;
/**
...
...
@@ -12,11 +13,13 @@ import org.springframework.web.bind.annotation.*;
@Api
(
tags
=
"测试接口"
)
@RequestMapping
(
"/main"
)
@RestController
@Slf4j
public
class
HelloWorldController
{
@ApiOperation
(
"新增代理商"
)
@GetMapping
(
"/hello"
)
public
String
hello
()
{
log
.
info
(
"hello world!"
);
return
"hello world!"
;
}
...
...
src/main/resources/application-publish.yml
0 → 100644
View file @
a7418a5f
spring
:
redis
:
database
:
5
host
:
192.168.1.2
port
:
6379
password
:
Aa11111111
timeout
:
300
jedis
:
pool
:
max-active
:
8
max-wait
:
-1
max-idle
:
8
min-idle
:
0
datasource
:
url
:
jdbc:mysql://39.170.1.99:3306/agent?characterEncoding=utf-8&useLocalSessionState=true&autoReconnect=true
username
:
agent
password
:
"
qMyWRrnPO@hcPlp@"
driver-class-name
:
com.mysql.jdbc.Driver
zing
:
open
:
api
:
public-key
:
"
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAlXV4b/1WUZ0J9Myvm3iAATAJsar
hKjMqBhcNVEVxVa/2zpLlQLMMEBNP5dRz5R8Y2kiAlKQI6Si5rzTEBohjTYzvIQDeBrNON9AuiYjqV8PH19
bv3YUEbVlE83wHKsuj5xJjuNR5E7ZCUdALirixzzozOaCK2damCcPhBvHd6ewoSrcACi2tmq8AqhuH1FXZl
yLYPwRgpEucj2SOeEGIPHTMH1i0lNc4nIbQ7Nle/1Li9KNvR0I02qspGfBjx+aPopzdzDu3b89uH0ncGish
IJWHK6ZwwvMmeOiqKJbJGSosXMBHIZLDrpsiCA6WJmpVYa9iRaGvMDkM3VRKwAsdcwIDAQAB"
private-key
:
"
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKg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55yCmt/gNcDeDS6tvCXa8RVy51RfSTQdMe8j
BEIY5BV8RN3FGupumSa6fI3LPnObSYup9rfCY8MxUUEW/ghll5fi9TobXXcngAij9RKn/px06mlEGg/W7Lg
B36VtdxK9pKFE+PAFjlKSWy982CqooqFh8XYkxQMOwKBgGl9H42CDtbwMkPGXxGuag3MD9XyFj1dZIz+57M
wbRkyV5ibEdQmt2E+9k02LjFGgUL2C76jB4EOYTXEus5fVS9bvLdJ3EA0AxNHRGWDpdk63iwJxXWIhKocLw
PDa3xUh3aivLiJ9e1FVjxBqHQXYFKbqtgfSya720tGZByBb6xRAoGBAMsDJF6HyCSenpohE786xUO9AXdPe
YjM7LMZi39a7Pdsb5j5CGEblKw5+9Prcm7geEJhO1If5ohVw2xNg/3XITEf6zkV2ygCOaOTxxg2x6jA92ee
ycpa0A/d4vqEcusu5+TdapclShroRi4821LvfzZobelkarefNPd7R3azaVI2
"
\ No newline at end of file
src/main/resources/docker/Dockerfile
0 → 100644
View file @
a7418a5f
FROM
centos-jdk8
ADD
demo-0.0.1-SNAPSHOT.jar /opt/app/demo-0.0.1-SNAPSHOT.jar
ENV
JAVA_HOME=/opt/jdk1.8.0_261
ENV
CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
ENV
PATH=$JAVA_HOME/bin:$PATH
ENTRYPOINT
[ \
"java","-Djava.security.egd=file:/dev/./urandom", \
"-Duser.timezone=Asia/Shanghai", \
"-jar","/opt/app/demo-0.0.1-SNAPSHOT.jar"]
\ No newline at end of file
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