首页 > 其他分享 >【Postopia Dev Log】Day 2

【Postopia Dev Log】Day 2

时间:2024-07-07 12:52:26浏览次数:10  
标签:Postopia image CMD Dev Gradle Docker Dockerfile Day instructions

考虑到不确定能把系统做到什么程度,暂时不考虑分布式相关事宜

运行./gradlew bootRun 热加载不知道为什么没有生效,找来找去没找到原因
想直接用dokcer实现,不熟悉docker和docker compose困难重重
根据 SpringBoot DevTools Auto Restart and Live Reload 一顿操作之后控制台有反应了,但是没有效果
根据 LiveReload does not detect changes
”For a change to be noticeable it has to be compiled. You can learn more about this ~in the reference documentation~. We generally recommend using an IDE to both to run the application and to make changes. It will then compile the changes so that they can be noticed by DevTools.“
解决问题

进度:
完成注册,热加载

knowledge

UUID, Long ID comparison

UUID:

  • Globally unique
  • 128-bit value
  • String representation
  • No sequential ordering
  • Suitable for distributed systems
  • Can be generated without DB interaction
  • Larger storage size (typically 36 characters)
    ⠀Long ID:
  • Locally unique (per table)
  • 64-bit integer
  • Numeric representation
  • Sequential (if auto-incremented)
  • Simpler and more human-readable
  • Smaller storage size (8 bytes)
  • Typically faster for indexing and joining

@GeneratedValue

The @GeneratedValue annotation in Spring Boot is used to specify how the primary key should be generated for an entity. Here's a breakdown of its key aspects:
Common strategies:

  • GenerationType.AUTO (default)
  • GenerationType.IDENTITY
    • Pros: Simple, efficient for single-node systems
    • Cons: Can cause issues in distributed systems or data migrations
  • GenerationType.SEQUENCE
    • Pros: Efficient, works well in high-concurrency environments
    • Cons: Not supported by all databases (e.g., MySQL before 8.0)
  • GenerationType.TABLE
    • Pros: Database-independent, works everywhere
    • Cons: Potentially slower, requires extra table management
  • @NoArgsConstructor
  • @AllArgsConstructor
  • @RequiredArgsConstructor
    all final and @NonNull fields
  • @Builder
    used to generate a builder pattern for your class
MyClass myClass = MyClass.builder()
                         .name("John Doe")
                         .age(30)
                         .address("123 Main St")
                         .build();

./gradlew

This part of the command is invoking the Gradle Wrapper (gradlew or gradlew.bat), which is a script that comes bundled with the Gradle build tool. The Gradle Wrapper ensures that the correct version of Gradle is used for the project, regardless of whether or not the user has Gradle installed on their system.

Dockerfile

A Dockerfile is a script that contains a series of instructions on how to build a Docker image. Each instruction in a Dockerfile creates a layer in the image, and when you build the image, Docker executes these instructions step by step to produce the final image.
FROM
Specifies the base image to use for the Docker image you’re building. Every Dockerfile must start with a FROM instruction.
FROM ubuntu:20.04

LABEL
Adds metadata to the image, such as a maintainer name or a version.
LABEL maintainer="[email protected]"

RUN
Executes a command in the shell. It’s often used for installing software packages.
RUN apt-get update && apt-get install -y nginx

COPY
Copies files or directories from your local filesystem into the Docker image.
COPY ./localfile /containerfile

ADD
Similar to COPY, but also supports URL sources and automatic unpacking of compressed files.
ADD https://example.com/file.tar.gz /tmp/

WORKDIR
Sets the working directory for any subsequent RUN, CMD, ENTRYPOINT, COPY, and ADD instructions.
WORKDIR /app

CMD
Provides a command that will be executed when a container is started from the image. Only one CMD instruction is allowed per Dockerfile; if multiple CMD instructions are specified, only the last one takes effect.
CMD ["nginx", "-g", "daemon off;"]

ENTRYPOINT
Sets the default application to be used every time a container is created from the image. Unlike CMD, ENTRYPOINT won’t be overridden by command-line arguments.
ENTRYPOINT ["nginx", "-g", "daemon off;"]

ENV
Sets environment variables.
ENV MY_ENV_VAR=my_value

EXPOSE
Informs Docker that the container listens on the specified network ports at runtime. This doesn’t actually publish the port; it’s a form of documentation.
EXPOSE 80

VOLUME
Creates a mount point with the specified path and marks it as holding externally mounted volumes from the native host or other containers.
VOLUME ["/data"]

USER
Sets the user name or UID to use when running the image and for any RUN, CMD, and ENTRYPOINT instructions that follow it.
USER nginx

a project can have multiple Dockerfiles.
e.g.
├── Dockerfile # Default Dockerfile for production
├── Dockerfile.dev # Dockerfile for development
├── Dockerfile.test # Dockerfile for testing

Articles

Using Docker Compose with Spring Boot and PostgreSQL
SpringBoot DevTools Auto Restart and Live Reload

标签:Postopia,image,CMD,Dev,Gradle,Docker,Dockerfile,Day,instructions
From: https://www.cnblogs.com/heslin/p/18288382

相关文章

  • day02-项目搭建+consul
    1RestTemplateRestTemplate提供了多种便捷访问远程Http服务的方法,是一种简单便捷的访问restful服务模板类,是Spring提供的用于访问Rest服务的客户端模板工具集官网地址:https://docs.spring.io/spring-framework/docs/6.0.11/javadoc-api/org/springframework/web/client/RestTe......
  • IAP 2023 Day1
    HTMLHTML是Hypertextmarkuplanguage(超文本标记语言),你可以理解为网页的结构。<!DOCTYPEhtml><html><head><title>ProfilePage</title><linkrel="stylesheet"href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta......
  • 代码随想录刷题day 4 | 两两交换链表中的节点 19.删除链表的倒数第N个节点 面试题
    24.两两交换链表中的节点迭代的版本:最重要的就是要知道循环变量怎么取,对于这道题,我们只需要存储需要交换的两个节点的前一个节点即可,只有当这个节点后面有两个节点时才进入循环,其实把握住这一点之后这题就非常容易了。递归的版本:这道题用递归做简直不要太简单,首先明白递归结束......
  • python随笔day02
    1.arg元组类型和**kwargs字典类型#元组参数:元组类型数据,对传递参数有顺序要求deftest(*args):print(f"args[0]={args[0]},args[1]={args[1]},args[2]={args[2]}")test(1,2,3)#字典参数:字典类型数据,对传递参数没有顺序要求,格式要求key=value值deftest2(**kwargs):......
  • JAVA学习day05
    继承supersuper();super调用父类的构造方法,且必须在构造方法的第一行。this();调用本类的构造方法。super只能出现在子类的方法或者构造方法中。super和this不能同时调用构造方法。this代表调用当前类的对象super代表调用父类的对象this在没有继承的情况下也能使用......
  • [未公开0day]宏景HCM人力资源信息管理系统存在前台RCE
    如果觉得该文章有帮助的,麻烦师傅们可以搜索下微信公众号:良月安全。点个关注,感谢师傅们的支持。payload就放在星球了,欢迎各位师傅来白嫖,看上眼的话可以留下试试。漏洞简介宏景人力资源管理系统是一款由宏景软件研发的系统,主要功能包括人员、组织机构、档案、合同、薪资、保险......
  • day01 初学c++第一章
    目录一、前置代码以及cout打印两条预处理代码:count打印语句:二、符号常量 三、标识符的命名规范四、数据类型 c++中整数类型的表现形式:在c++中,数字存在有符号和无符号之分的c++中实型的表现形式:代码所用函数:c++中字符型的表现形式:基础运算总结:转义字符c++中字......
  • Day02
    总结Java特性:简单性,面向对象,可移植性(跨平台),高性能,分布式,动态性,多线程,安全性,健壮性单行注释://多行注释:/**/文档注释:JavaDoc:/***/强类型语言:安全性高,速度低,所有变量必须先定义后使用,使用要严格符合规定。数据类型变量名=值;弱类型语言:在JS中运用较多。位bit:数据存储......
  • Day01
    快捷键ctrl+shift切换输入法ctrl+X剪切Ctrl+S保存alt+F4关闭窗口shift+delete永久删除Ctrl+shift+ESC打开任务管理器Windows+E我的电脑Windows+R打开cmd,命令提示符磁盘前+cmd打开cmdCtrl+D:复制当前到下一行DOS命令盘符切换:D:/E:/F:查看当前目录的所有......
  • 从零学习的JAVAday1~day7
    作为一个刚要迈入大二的预备程序员,已经学习过了c语言和c++的部分知识,在暑假期间满怀期待的开始Java的学习,希望一个暑假可以对Java的了解加深一些。学习Java首先要学习windows电脑的cmd命令:同时点击键盘上面的win+r键输入cmd即可进入默认的cmd面版,然后我们就可以输入一些命令:比......