This service is simple chatting server using websocket protocol. The reason why I develop this service is to learn websocket concept.
Kotlin, Spring(MVC, Websocket, Redis, Security, Freemarker), JJWT ..
Vue
If you want to know more information about my project's tech referencing gradle file
/chat/rooms
: Get all chat-room information/chat/room/{roomId}
: Get specified chat-room information/chat/room?name="chatRoomName
: create new chat-room/chat/user
: get current user info
/ws-stomp
: connect stomp/sub/chat/room/{roomId}
: subscribe roomId topic/pub/chat/message
: publish message to specific topic (message include topic information)
# clone project and move to project folder
git clone https://github.com/hyuk0309/playground-chat-server.git
cd ./playground-chat-server/
# build and execute project
./gradlew clean build
cd ./build.libs
java -jar playground-chat-server-0.0.1-SNAPSHOT.jar
-
WebSocket Protocol & Spring Support
-
STOMP & Spring Support
-
spring data redis pub sub
- ref
- redis docs : https://redis.io/docs/manual/pubsub/
- spring docs : https://spring.io/guides/gs/messaging-redis/
- blog : https://www.baeldung.com/spring-data-redis-pub-sub
- blog : https://brunch.co.kr/@springboot/374
- my blog : https://hyuk0309.tistory.com/21
- ref
-
@Resource
principle- code
@Repository class ChatRoomRepository { @Resource(name = "redisTemplate") private lateinit var hashOpsChatRoom: HashOperations<String, String, ChatRoom> @Resource(name = "redisTemplate") private lateinit var hashOpsEnterInfo: HashOperations<String, String, String> @Resource(name = "redisTemplate") private lateinit var valueOps: ValueOperations<String, String> ... }
- Question? : How Spring Inject Dependency when
name
bean and target bean are different.- Answer : there is converter helping that task.
- ref
- logic start : org.springframework.beans.factory.support.AbstractBeanFactory.adaptBeanInstance
- key class : org.springframework.data.redis.core.HashOperationsEditor
- ref
- Answer : there is converter helping that task.
- FreeMarkerViewReolver's default suffix
- Reason : dafult suffix : .htlh
- Solution : change
ftl
extension toftlh
- Can't find Webjar Dependency
- Solution : add Resource Handler
- SLF4J multi binding Issue
- Reason : SLF4J will bind with one logging framework at a time. but my classpath have two binder(provider)
- Solution : exclude one logging framework using gradle.
- ref :
- Listing dependency tree : https://docs.gradle.org/7.3/userguide/viewing_debugging_dependencies.html#sec:listing_dependencies
- exclude specific module : https://docs.gradle.org/current/userguide/dependency_downgrade_and_exclude.html#sec:excluding-transitive-deps
- how to know group and module name : https://stackoverflow.com/questions/43582247/how-to-know-if-duplicate-library-is-module-or-group
- ref :
- Spring Securit's WebSecurityConfigurerAdapter was deprecated
- JJWT(jsonwebtoken) deprecated api
- Reason : confused api
- ref : https://stackoverflow.com/questions/40252903/static-secret-as-byte-key-or-string/40274325#40274325
- The difference between the Spring Container in an operational environment and the Spring Container in a testing environment
- reason : When testing, If we use
WebEnvironment.MOCK
, than SpringBootContextLoader loadGenericWebApplicationContext
. But, If we useWebEnvironment.RANDOM_PORT
orWebEnvironment.DEFINED_PORT
, than loadAnnotationConfigServletWebServerApplicationContext
.
- reason : When testing, If we use
-
Example Code
-
Official Docs