This commit is contained in:
2025-07-17 11:00:22 +08:00
28 changed files with 154 additions and 13 deletions

35
Jenkinsfile vendored
View File

@ -8,17 +8,39 @@ pipeline {
}
stages {
stage('Pre') {
stage('Pull Code') {
steps {
sshagent([env.SSH_CREDENTIALS_ID]) {
sh 'ssh alex@117.72.202.202 "bash /home/alex/alex-api/bin/pre-steps.sh"'
sh """
ssh ${REMOTE_USER}@${REMOTE_HOST} '
set -e
cd ${REMOTE_DIR} || git clone git@117.72.202.202:ALEX/alex-api.git ${REMOTE_DIR}
cd ${REMOTE_DIR}
git pull origin master
'
"""
}
}
}
stage('Pre Steps') {
steps {
sshagent([env.SSH_CREDENTIALS_ID]) {
sh "ssh ${REMOTE_USER}@${REMOTE_HOST} 'bash ${REMOTE_DIR}/bin/pre-steps.sh'"
}
}
}
stage('Build') {
steps {
sh 'mvn clean package -DskipTests'
sshagent([env.SSH_CREDENTIALS_ID]) {
sh """
ssh ${REMOTE_USER}@${REMOTE_HOST} '
cd ${REMOTE_DIR}
mvn clean package -DskipTests
'
"""
}
}
}
@ -26,10 +48,10 @@ pipeline {
steps {
sshagent([env.SSH_CREDENTIALS_ID]) {
sh """
scp target/alex-api-0.0.1-SNAPSHOT.jar ${REMOTE_USER}@${REMOTE_HOST}:${REMOTE_DIR}/app/
ssh ${REMOTE_USER}@${REMOTE_HOST} '
cd ${REMOTE_DIR} &&
sudo docker compose down &&
cd ${REMOTE_DIR}
sudo docker compose down
sudo docker image prune -f
sudo docker compose up -d --build
'
"""
@ -38,4 +60,3 @@ pipeline {
}
}
}

Binary file not shown.

View File

@ -3,7 +3,7 @@ server:
port: 8888
spring:
profiles:
active: dev # 默认激活开发环境
active: test
#配置mybatis
mybatis:
configuration:

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,12 @@
spring:
datasource:
type: com.zaxxer.hikari.HikariDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/test_alex?characterEncoding=UTF-8&useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true
username: root
password: ALEXzcz123456
redis:
host: localhost
password: ALEXzcz123456
port: 6379
database: 0

View File

@ -0,0 +1,12 @@
spring:
datasource:
type: com.zaxxer.hikari.HikariDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://117.72.202.202:3306/test_alex?characterEncoding=UTF-8&useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true
username: alex
password: ALEXzcz123456
redis:
host: 117.72.202.202
password: ALEXzcz123456
port: 6379
database: 0

View File

@ -0,0 +1,12 @@
spring:
datasource:
type: com.zaxxer.hikari.HikariDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://117.72.202.202:3306/test_alex?characterEncoding=UTF-8&useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true
username: alex
password: ALEXzcz123456
redis:
host: 117.72.202.202
password: ALEXzcz123456
port: 6379
database: 0

View File

@ -0,0 +1,41 @@
server:
address: 0.0.0.0
port: 8888
spring:
profiles:
active: test
#配置mybatis
mybatis:
configuration:
auto-mapping-behavior: full
map-underscore-to-camel-case: true
log-impl: org.apache.ibatis.logging.slf4j.Slf4jImpl
type-aliases-package: com.anytrek.entity # 配置别名路径
mapper-locations: classpath:mapper/*.xml # 配置 XML 文件位置
#配置mybatis-plus
mybatis-plus:
configuration:
log-impl: org.apache.ibatis.logging.slf4j.Slf4jImpl
global-config:
db-config:
table-prefix: t_
id-type: auto
#配置分页插件
pagehelper:
helperDialect: mysql
params: count=countSql
reasonable: true
supportMethodsArguments: true
#配置日志
logging:
level:
root: INFO #根日志配置,整个应用程序的默认日志级别为 INFO
com.anytrek: DEBUG #com.anytrek 包下的类的日志级别设置为 DEBUG
org.apache.ibatis: INFO #MyBatis 日志级别设置为 INFO
com.zaxxer.hikari: INFO #HikariCP 的日志级别设置为 INFO
org.springframework.web.socket: DEBUG
org.springframework.web.socket.server.support: DEBUG
org:
springframework:
integration: DEBUG
messaging: DEBUG

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,16 @@
<?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.ctgu.alexapi.mapper.UsersMapper">
<resultMap id="BaseResultMap" type="com.ctgu.alexapi.entity.UsersEntity">
<id property="id" column="id" jdbcType="INTEGER"/>
<result property="username" column="username" jdbcType="VARCHAR"/>
<result property="password" column="password" jdbcType="VARCHAR"/>
</resultMap>
<sql id="Base_Column_List">
id,username,password
</sql>
</mapper>

View File

@ -0,0 +1,3 @@
artifactId=alex-api
groupId=com.ctgu
version=0.0.1-SNAPSHOT

View File

@ -0,0 +1,12 @@
com/ctgu/alexapi/utils/PageData.class
com/ctgu/alexapi/utils/ApiResult$ApiResultBuilder.class
com/ctgu/alexapi/controller/UsersController.class
com/ctgu/alexapi/utils/ApiResult.class
com/ctgu/alexapi/mapper/UsersMapper.class
com/ctgu/alexapi/utils/PageData$PageDataBuilder.class
com/ctgu/alexapi/AlexApiApplication.class
com/ctgu/alexapi/service/impl/UsersServiceImpl.class
com/ctgu/alexapi/utils/Tools.class
com/ctgu/alexapi/service/UsersService.class
com/ctgu/alexapi/config/RedisConfig.class
com/ctgu/alexapi/entity/UsersEntity.class

View File

@ -0,0 +1,10 @@
/home/alex/alex-api/src/main/java/com/ctgu/alexapi/mapper/UsersMapper.java
/home/alex/alex-api/src/main/java/com/ctgu/alexapi/entity/UsersEntity.java
/home/alex/alex-api/src/main/java/com/ctgu/alexapi/utils/PageData.java
/home/alex/alex-api/src/main/java/com/ctgu/alexapi/utils/ApiResult.java
/home/alex/alex-api/src/main/java/com/ctgu/alexapi/utils/Tools.java
/home/alex/alex-api/src/main/java/com/ctgu/alexapi/service/UsersService.java
/home/alex/alex-api/src/main/java/com/ctgu/alexapi/config/RedisConfig.java
/home/alex/alex-api/src/main/java/com/ctgu/alexapi/service/impl/UsersServiceImpl.java
/home/alex/alex-api/src/main/java/com/ctgu/alexapi/AlexApiApplication.java
/home/alex/alex-api/src/main/java/com/ctgu/alexapi/controller/UsersController.java

View File

@ -0,0 +1 @@
com/ctgu/alexapi/AlexApiApplicationTests.class

View File

@ -0,0 +1 @@
/home/alex/alex-api/src/test/java/com/ctgu/alexapi/AlexApiApplicationTests.java