Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tht server 272 spring boot 3.4.1 마이그레이션 #273

Merged
merged 6 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions .github/workflows/APP-Server-gradle-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ jobs:
token: ${{ secrets.GIT_TOKEN }}
submodules: true

- name: Set up JDK 17
- name: Set up JDK 21
uses:
actions/setup-java@v4
with:
java-version: '17'
java-version: '21'
distribution: 'temurin'
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
settings-path: ${{ github.workspace }} # location for the settings.xml file
Expand All @@ -64,8 +64,11 @@ jobs:
restore-keys: |
${{ github.repository }}-gradle-

- name: Build with Gradle
run: ./gradlew clean tht-apis:clean tht-apis:build
- name: Build with Gradle (NO TEST)
run: ./gradlew clean tht-apis:clean tht-apis:build -x test

- name: gradle run test
run: ./gradlew tht-apis:test

- name: make env now date
id: now
Expand Down
58 changes: 49 additions & 9 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,34 @@
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile

buildscript {
ext {
kotlinVersion = '2.1.0'
springBootVersion = '3.4.1'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlinVersion}")
classpath("org.jetbrains.kotlin:kotlin-allopen:${kotlinVersion}")
classpath("org.jetbrains.kotlin:kotlin-noarg:${kotlinVersion}")
}
}

plugins {
id 'java'
id 'org.springframework.boot' version '3.0.5'
id 'io.spring.dependency-management' version '1.1.0'
id 'org.springframework.boot' version "${springBootVersion}"
id 'io.spring.dependency-management' version '1.1.3'

id 'org.jetbrains.kotlin.jvm' version "${kotlinVersion}"
id 'org.jetbrains.kotlin.plugin.spring' version "${kotlinVersion}"
id 'org.jetbrains.kotlin.plugin.jpa' version "${kotlinVersion}"
id 'org.jetbrains.kotlin.kapt' version "${kotlinVersion}"
id 'org.jetbrains.kotlin.plugin.lombok' version "${kotlinVersion}"
id 'io.freefair.lombok' version '8.1.0'
id 'idea'
}

bootJar {enabled = false}
Expand All @@ -10,8 +37,8 @@ jar {enabled = true}
allprojects {
group = 'com.tht'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '17'
targetCompatibility = '17'
sourceCompatibility = '21'
targetCompatibility = '21'

repositories {
mavenCentral()
Expand All @@ -31,15 +58,18 @@ subprojects {
apply plugin: "io.spring.dependency-management"
apply plugin: "java-test-fixtures"

// apply plugin: "com.epages.restdocs-api-spec"
// apply plugin: "org.hidetake.swagger.generator"

test {
useJUnitPlatform()
}

dependencies {

//kotlin
implementation 'org.jetbrains.kotlin:kotlin-reflect'
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8'
implementation 'com.fasterxml.jackson.module:jackson-module-kotlin'

//spring boot
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.apache.commons:commons-lang3:3.12.0'
Expand All @@ -57,7 +87,7 @@ subprojects {
implementation 'org.springframework.boot:spring-boot-starter-data-mongodb'

//in-memory-mongo
testImplementation 'de.bwaldvogel:mongo-java-server:1.44.0'
testImplementation 'de.bwaldvogel:mongo-java-server:1.46.0'

// https://mvnrepository.com/artifact/com.mysql/mysql-connector-j
implementation 'com.mysql:mysql-connector-j:8.0.32'
Expand All @@ -69,8 +99,18 @@ subprojects {
implementation group: 'com.googlecode.json-simple', name: 'json-simple', version: '1.1.1'

// https://mvnrepository.com/artifact/jakarta.persistence/jakarta.persistence-api
implementation 'jakarta.persistence:jakarta.persistence-api:3.2.0'
implementation 'jakarta.persistence:jakarta.persistence-api'

}
}

kapt {
keepJavacAnnotationProcessors = true
}

tasks.withType(KotlinJvmCompile).configureEach {
compilerOptions {
jvmTarget.set(JvmTarget.JVM_21)
freeCompilerArgs.add("-opt-in=kotlin.RequiresOptIn")
}
}
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 3 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
35 changes: 22 additions & 13 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand All @@ -80,13 +80,11 @@ do
esac
done

APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

APP_NAME="Gradle"
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down Expand Up @@ -133,22 +131,29 @@ location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.

Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi

# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -193,11 +198,15 @@ if "$cygwin" || "$msys" ; then
done
fi

# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.

set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
Expand Down
1 change: 1 addition & 0 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ if "%OS%"=="Windows_NT" setlocal

set DIRNAME=%~dp0
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

Expand Down
3 changes: 3 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
plugins {
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.5.0'
}
rootProject.name = 'server'
include('tht-apis')
include('tht-admin')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
import org.springframework.boot.autoconfigure.security.servlet.PathRequest;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.Customizer;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer;
import org.springframework.security.web.SecurityFilterChain;
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
import org.springframework.web.cors.CorsConfiguration;
Expand All @@ -17,6 +17,8 @@

import java.util.List;

import static org.springframework.security.config.Customizer.withDefaults;

@Configuration
@EnableWebSecurity
@RequiredArgsConstructor
Expand All @@ -36,10 +38,10 @@ public class SecurityConfiguration {
public SecurityFilterChain securityFilterChain(HttpSecurity httpSecurity) throws Exception {

httpSecurity
.csrf().disable()
.cors(Customizer.withDefaults())
.httpBasic().disable()
.exceptionHandling();
.csrf(AbstractHttpConfigurer::disable)
.cors(withDefaults())
.httpBasic(AbstractHttpConfigurer::disable)
.exceptionHandling(withDefaults());

return httpSecurity
.authorizeHttpRequests(
Expand All @@ -50,11 +52,9 @@ public SecurityFilterChain securityFilterChain(HttpSecurity httpSecurity) throws
.requestMatchers("create").permitAll()
.requestMatchers(SWAGGER_URL_ARRAY).permitAll()
.anyRequest().hasAuthority("ADMIN")

.and()
.addFilterBefore(jwtFilter, UsernamePasswordAuthenticationFilter.class)
.addFilterBefore(exceptionHandlerFilter, JwtFilter.class)
)
.addFilterBefore(jwtFilter, UsernamePasswordAuthenticationFilter.class)
.addFilterBefore(exceptionHandlerFilter, JwtFilter.class)
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.test.context.bean.override.mockito.MockitoBean;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.http.MediaType;
Expand All @@ -42,7 +42,7 @@
@WebMvcTest(UserManageController.class)
class UserManageDocs extends ControllerTestConfig {

@MockBean
@MockitoBean
UserManageUseCase userManageUseCase;

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
import com.tht.domain.entity.administrator.AdministratorService;
import com.tht.thtadmin.security.TokenProvider;
import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.test.context.bean.override.mockito.MockitoBean;
import org.springframework.context.annotation.Bean;

@TestConfiguration
public class TokenProviderConfig {

@MockBean
@MockitoBean
AdministratorService userService;

@Bean
Expand Down
8 changes: 8 additions & 0 deletions tht-apis/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ plugins{
id 'com.epages.restdocs-api-spec' version "${restdocsApiSpecVersion}"
//swagger generator 플러그인 추가
id 'org.hidetake.swagger.generator' version '2.18.2'
id 'org.jetbrains.kotlin.jvm'
}

bootJar { enabled = true }
Expand Down Expand Up @@ -46,6 +47,7 @@ dependencies {
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.6.0'
// https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind
implementation 'com.fasterxml.jackson.core:jackson-databind'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
}

openapi3 {
Expand Down Expand Up @@ -80,4 +82,10 @@ bootJar{
into "src/main/resources/static/docs/"

}
}
repositories {
mavenCentral()
}
kotlin {
jvmToolchain(21)
}
38 changes: 38 additions & 0 deletions tht-apis/src/main/java/com/tht/thtapis/dev/DevController.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.tht.thtapis.dev

import com.tht.domain.entity.like.UserLikeRepository
import com.tht.domain.entity.user.repository.UserDailyFallingRepository
import lombok.RequiredArgsConstructor
import org.springframework.http.HttpStatus
import org.springframework.http.ResponseEntity
import org.springframework.security.core.Authentication
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController
import java.util.*

@RestController
@RequestMapping("/dev")
@RequiredArgsConstructor
class DevController(
private val userLikeRepository: UserLikeRepository,
private val userDailyFallingRepository: UserDailyFallingRepository
) {

@PostMapping("/like-and-dislike/reset")
fun resetLikeData(authentication: Authentication?): ResponseEntity<Objects> {
val userUuid: String = authentication?.credentials.toString()
userLikeRepository.deleteAllByUserUuid(userUuid)

return ResponseEntity.status(HttpStatus.NO_CONTENT).build()
}

@PostMapping("/selected-talk-keywords/reset")
fun resetSelectedFallingKeyword(authentication: Authentication?): ResponseEntity<Objects> {
val userUuid: String = authentication?.credentials.toString()
userDailyFallingRepository.deleteAllByUserUuid(userUuid)

return ResponseEntity.status(HttpStatus.NO_CONTENT).build()
}

}
Loading
Loading