pom.xml文件
在Java项目中,POM (Project Object Model) 文件是Maven项目管理工具中的核心文件之一。它是一个XML文件,通常命名为pom.xml
,用于描述项目的基本信息、依赖关系、构建配置等。pom.xml 是spring boot项目“起步依赖”的文件。下面是pom.xml
文件可能包含的一些内容:
1.项目基本信息:包括项目的groupId
(项目组ID)、artifactId
(项目唯一标识符)、version
(项目版本)、name
(项目名称)、description
(项目描述)等。
<groupId>com.example</groupId>
<artifactId>my-project</artifactId>
<version>1.0.0</version>
<name>My Project</name>
<description>This is a sample Maven project.</description>
2.依赖管理:描述项目所依赖的外部库或模块。每个依赖项包括groupId
、artifactId
和version
等信息。
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>5.3.2</version>
</dependency>
<!-- Other dependencies -->
</dependencies>
3. 构建配置:描述项目如何构建的配置信息,例如编译器版本、源代码目录、资源目录、插件配置等。
<build>
<sourceDirectory>src/main/java</sourceDirectory>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
<!-- Plugin configurations -->
</build>
4.插件配置:配置Maven插件的参数,用于执行各种构建任务,如编译、测试、打包等
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<!-- Other plugins -->
</plugins>
</build>
5.仓库配置:指定项目依赖项所在的Maven仓库,可以是本地仓库或远程仓库。
<repositories>
<repository>
<id>central</id>
<url>https://repo.maven.apache.org/maven2</url>
</repository>
<!-- Other repositories -->
</repositories>
总的来说,pom.xml
文件是Maven项目的核心配置文件,定义了项目的结构、依赖关系、构建过程等重要信息,使得Maven能够管理项目的构建、依赖和部署。
resource/application.yaml文件
配置文件,比如在pom.xml文件中引入了mybatis,mysql驱动,那么需要在application.yaml文件中配置信息:
mybatis:
configuration:
#开启驼峰映射后,会把数据库字段下划线格式映射为java实体类的驼峰格式,如果实体类属性也是下划线格式,那无法映射上
map-underscore-to-camel-case: false
cache-enabled: false #全局关闭缓存
multiple-result-sets-enabled: true #是否允许单条sql 返回多个数据集
use-column-label: true
use-generated-keys: true
auto-mapping-behavior: partial
default-executor-type: simple