Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to deploy springboot+mysql project in docker-compose

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

Docker-compose how to deploy the springboot+mysql project, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain for you in detail, people with this need can come to learn, I hope you can gain something.

1. Core file docker-compose.yml

Version: '3'services: mysql: container_name: v-mysql image: mysql:5.7 environment: MYSQL_ROOT_PASSWORD: 123456 MYSQL_ROOT_HOST:'% 'ports:-"3306 always pm_docker: container_name: pm_docker working_dir: / pm-docker-mysql build:. / pm-docker-mysql volumes:- . / pm-docker-mysql:/pm-docker-mysql-~ / .m2:/root/.m2 ports:-8080 restart: always depends_on:-mysql command: mvn clean spring-boot:run-Dmaven.skip.test=true

Database application.yml start:

Spring: datasource: url: jdbc:mysql://mysql:3306/test?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8&useSSL=false&allowPublicKeyRetrieval=true username: root password: 123456 driver-class-name: com.mysql.jdbc.Driver mybatis: mapperLocations: classpath:mapper/*.xml typeAliasesPackage: com.pimee.model

Got it. Startup code: docker-compose up-d

1. Start the direct rhetorical question: http://xxx:8080/hello/name

You can see the result returned normally: Hello, name

two。 You need to test the link with the database: http://xxx:8080/user/get?userId=1

{"id": 1, "userName": "bobo", "password": "123456", "age": 18} is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report