UserSpice Dotclear Java特价

Gitee:a7. (JiaBin1) – Gitee.com
1、特价Docker
#1.需要的特价包yum install -y yum-utils #2.设置镜像的仓库yum-config-manager \ –add-repo \ #使用阿里云仓库 #更新yum软件包索引yum makecache fast #3.特价docker相关的内容yum install docker-ce docker-ce-cli containerd.io #4.启动dockersystemctl start docker #5.查看当前docker版本docker version
2、特价Docker-Compose
#1、下载sudo curl -L ” -s)-$(uname -m)” -o /usr/local/bin/docker-compose # 这个可能快点!curl -L -s`-`uname -m` > /usr/local/bin/docker-compose #2、授权sudo chmod +x /usr/local/bin/docker-compose
3、部署SpringBoot + MySQL
1、创建SpringBoot项目,导入以下依赖
org.springframework.boot spring-boot-starter-web org.springframework.boot spring-boot-starter-test test org.mybatis.spring.boot mybatis-spring-boot-starter 2.2.2 com.alibaba fastjson 1.2.76 mysql mysql-connector-java 5.1.48 org.projectlombok lombok
2、搭建基础环境架构
【实体类】

/** * @Author Dotclear * @Data 2022/3/21 14:54 * @Version 1.0 */@Data@AllArgsConstructor@NoArgsConstructorpublic class Person { private Integer pid; private String pname; private Integer psex;}
【接口】
/** * @Author Dotclear * @Data 2022/3/21 14:55 * @Version 1.0 */@Mapperpublic interface PersonMapper { /** * 查询全部信息 */ List findAll();}
【mapper映射】
【service】
/** * @Author Dotclear * @Data 2022/3/21 14:57 * @Version 1.0 */public interface PersonService { /** * 查询全部信息 */ List findAll();}
【impl】
/** * @Author Dotclear * @Data 2022/3/21 14:57 * @Version 1.0 */@Servicepublic class PersonServiceImpl implements PersonService { @Autowired private PersonMapper personMapper; @Override public List findAll() { return personMapper.findAll(); }}
【controller】
/** * @Author Dotclear * @Data 2022/3/21 14:58 * @Version 1.0 */@RestController@RequestMapping(“/person”)public class PersonController { @Autowired private PersonService personService; @GetMapping(“/findAll”) public String findAll(){ List personList = personService.findAll(); return personList.toString(); } @GetMapping(“/hello”) public String hello(){ return “

Hello.JiaBin!“; }}
【配置文件】
spring.datasource.driver-class-name=com.mysql.jdbc.Driver#这里填写UserSpice名即可mysqldbserver,无需Java号spring.datasource.url=jdbc: mybatis.mapper-locations=classpath:mapper/*.xmlmybatis.type-aliases-package=com.jiabin.pojo
3、Dockerfile1
FROM java:8 VOLUME /vol/development RUN mkdir -p /vol/development WORKDIR /vol/development COPY 这里需要改为自己的jar包.jar /vol/development/app.jar CMD [“java”, “-Xmx200m”, “-Djava.security.egd=file:/dev/./urandom”,”-jar”,”/vol/development/app.jar”]
4、Dockerfile
FROM mysql:5.7.17
5、docker-compose.yml
version : ‘3’services: #sqlUserSpice mysqldbserver: #UserSpice名称 container_name: mysqldbserver #镜像 image: mysql:5.7.17 build: context: . dockerfile: Dockerfile #Java ports: – “3306:3306” command: [ #执行多条指令 ‘mysqld’, ‘–innodb-buffer-pool-size=20M’, ‘–character-set-server=utf8’, ‘–collation-server=utf8_general_ci’, ‘–default-time-zone=+8:00’, ‘–lower-case-table-names=1’ ] environment: # 数据库 MYSQL_DATABASE: sys # 设置root用户密码 MYSQL_ROOT_PASSWORD: 123456 #springUserSpice springappserver: # UserSpice名称 container_name: springappserver build: context: . dockerfile: Dockerfile1 ports: #Java – “8080:8080” volumes: #数据卷 – /vol/development depends_on: – mysqldbserver links: #连接sql – mysqldbserver
6、将项目打包以及上述三个配置文件统一上传到我们的UserSpice器

7、使用命令docker-compose up部署,通过ip+Java号访问项目即可!