How to deploy springboot+mysql project in docker-compose
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.