This commit is contained in:
병준 박 2019-07-22 21:08:28 +09:00
parent 1cc236a683
commit 916dca0207
8 changed files with 106 additions and 51 deletions

18
pom.xml
View File

@ -16,6 +16,7 @@
<properties>
<java.version>1.8</java.version>
<gson.version>2.8.5</gson.version>
</properties>
<dependencies>
@ -30,6 +31,13 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<!-- Exclude the default Jackson dependency -->
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-json</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
@ -39,6 +47,11 @@
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka</artifactId>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>${gson.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
@ -46,11 +59,6 @@
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>

View File

@ -0,0 +1,15 @@
package com.totopia.server;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
@SpringBootApplication
@EnableAutoConfiguration(exclude = { JacksonAutoConfiguration.class })
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}

View File

@ -0,0 +1,30 @@
package com.totopia.server;
import com.google.gson.ExclusionStrategy;
import com.google.gson.FieldAttributes;
import com.totopia.server.commons.base.gson.annotation.Exclude;
import org.springframework.boot.autoconfigure.gson.GsonBuilderCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class ApplicationGsonExclusionStrategy {
@Bean
GsonBuilderCustomizer gsonBuilderCustomizer() {
return (gsonBuilder) -> gsonBuilder.addSerializationExclusionStrategy(new ExclusionStrategy() {
@Override
public boolean shouldSkipField(FieldAttributes f) {
return f.getAnnotation(Exclude.class) != null;
}
@Override
public boolean shouldSkipClass(Class<?> clazz) {
return false;
}
});
}
}

View File

@ -1,12 +0,0 @@
package com.totopia.server;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class ServerApplication {
public static void main(String[] args) {
SpringApplication.run(ServerApplication.class, args);
}
}

View File

@ -0,0 +1,11 @@
package com.totopia.server.commons.base.gson.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface Exclude {
}

View File

@ -5,7 +5,7 @@ import java.util.Date;
import javax.persistence.*;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.totopia.server.commons.base.gson.annotation.Exclude;
import lombok.AllArgsConstructor;
import lombok.Builder;
@ -34,7 +34,7 @@ public class User implements Serializable {
@Basic
@Column(name = "password", nullable = false, length = 100)
@JsonIgnore
@Exclude
private String password;
@Basic

View File

@ -1,6 +1,5 @@
package com.totopia.server.user.model;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
@ -18,6 +17,8 @@ import java.util.Date;
@NoArgsConstructor
@AllArgsConstructor
public class UserGroup implements Serializable {
private static final long serialVersionUID = 4801565634000630034L;
@Id
@GeneratedValue(generator = "user_group_generator")
@SequenceGenerator(name = "user_group_generator", sequenceName = "user_group_sequence", initialValue = 1, allocationSize = 1)
@ -25,7 +26,6 @@ public class UserGroup implements Serializable {
@Basic
@Column(name = "title", nullable = false, length = 100)
@JsonIgnore
private String title;
@Basic

View File

@ -1,42 +1,45 @@
# Spring Boot configuration
spring:
application:
name: totopia-server
h2:
console:
enabled: true
path: /h2-console
datasource:
driver-class-name: org.postgresql.Driver
url: jdbc:postgresql://localhost:15432/postgres
data-username: postgres
password: qwer5795
username: postgres
# JPA properties
initialization-mode: never
jpa:
hibernate:
ddl-auto: update
database: postgresql
show-sql: true
database-platform: org.hibernate.dialect.PostgreSQLDialect
properties:
application:
name: totopia-server
http:
converters:
preferred-json-mapper: gson
h2:
console:
enabled: true
path: /h2-console
datasource:
driver-class-name: org.postgresql.Driver
url: jdbc:postgresql://localhost:15432/postgres
data-username: postgres
username: postgres
password: qwer5795
# JPA properties
initialization-mode: never
jpa:
hibernate:
ddl-auto: update
database: postgresql
show-sql: true
database-platform: org.hibernate.dialect.PostgreSQLDialect
properties:
hibernate:
temp:
use_jdbc_metadata_defaults: false
# Logger configuration
logging:
pattern:
console: "%d %-5level %logger : %msg%n"
level:
org.springframework: INFO
org.hibernate: DEBUG
pattern:
console: "%d %-5level %logger : %msg%n"
level:
root: ERROR
org.springframework: INFO
org.hibernate: DEBUG
# Server configuration
server:
port: 8088
servlet:
context-path: /api
port: 8088
servlet:
context-path: /api