创建springboot项目

SpringBoot 就相当于不需要配置文件的Spring+SpringMVC。 常用的框架和第三方库都已经配置好了。

maven安装配置

管理项目依赖库的

maven的安装教程网上有很多,这里简单记录一下。

官网下载maven后并解压。
在这里插入图片描述

在其目录下添加一个目录repository

然后在conf目录下配置setting.xml文件,主要配置<localRepository></localRepository> <mirror></mirror>​​这两个标签

<localRepository></localRepository>里指定刚刚repository的路径;
<mirror></mirror>里配置获取依赖的镜像资源路径

<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
		  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
		  xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">  
 <localRepository>D:\installpath\apache-maven-3.6.1\repository</localRepository>	 
  <pluginGroups>	
  </pluginGroups>	
  <proxies>		
  </proxies>
  <servers>
  </servers>
  <mirrors>
	 <mirror>      
		<id>nexus-aliyun</id>    
		<name>nexus-aliyun</name>  
		 <url>http://maven.aliyun.com/nexus/content/groups/public</url>    
		<mirrorOf>central</mirrorOf>      
	</mirror>  
  </mirrors>

  <profiles>
	<profile>
		<id>jdk-1.8</id>
		<activation>
			<activeByDefault>true</activeByDefault>
			<jdk>1.8</jdk> 
		</activation>	 
	<properties>	 
	<maven.compiler.source>1.8</maven.compiler.source>	 
	<maven.compiler.target>1.8</maven.compiler.target>	 
	<maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>	 
	</properties>	 
	</profile>
  </profiles>
</settings>

可以在环境变量中配置一下maven的路径。
在这里插入图片描述

IDEA关联maven

在这里插入图片描述

方式一:使用spring boot 提供的初始化器

使用 spring boot 提供的初始化器。 向导的方式,完成 spring boot 项目的创建: 使用方便。
在这里插入图片描述
在这里插入图片描述
新建好后,在pom.xml中很多依赖
这是起步依赖
在这里插入图片描述

方式二:使用maven向导创建项目

然后手动添加配置文件等
在这里插入图片描述
然后再pom.xml中手动添加springboot依赖

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.example</groupId>
    <artifactId>javaWeb</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>javaWeb</name>
    <description>javaWeb</description>
    <properties>
        <java.version>1.8</java.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <spring-boot.version>2.6.13</spring-boot.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.mybatis.spring.boot</groupId>
            <artifactId>mybatis-spring-boot-starter</artifactId>
            <version>2.2.2</version>
        </dependency>

        <dependency>
            <groupId>com.mysql</groupId>
            <artifactId>mysql-connector-j</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-dependencies</artifactId>
                <version>${spring-boot.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <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>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>${spring-boot.version}</version>
                <configuration>
                    <mainClass>com.swl.javaweb.JavaWebApplication</mainClass>
                    <skip>true</skip>
                </configuration>
                <executions>
                    <execution>
                        <id>repackage</id>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

</project>

相关推荐

  1. 创建第一个SpringBoot项目

    2023-12-25 03:32:02       32 阅读
  2. idea 使用springboot helper 创建springboot项目

    2023-12-25 03:32:02       10 阅读

最近更新

  1. TCP协议是安全的吗?

    2023-12-25 03:32:02       16 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2023-12-25 03:32:02       16 阅读
  3. 【Python教程】压缩PDF文件大小

    2023-12-25 03:32:02       15 阅读
  4. 通过文章id递归查询所有评论(xml)

    2023-12-25 03:32:02       18 阅读

热门阅读

  1. C++:第十讲二分查找

    2023-12-25 03:32:02       40 阅读
  2. 7-2 非递归二路归并排序

    2023-12-25 03:32:02       36 阅读
  3. 超酷的爬虫可视化界面

    2023-12-25 03:32:02       37 阅读
  4. C#字典和列表转LuaTable

    2023-12-25 03:32:02       36 阅读
  5. LeeCode前端算法基础100题(15)-最大子数组和

    2023-12-25 03:32:02       31 阅读
  6. leetcode203题目移除链表元素

    2023-12-25 03:32:02       32 阅读
  7. 【.NET Core】反射(Reflection)详解(二)

    2023-12-25 03:32:02       38 阅读
  8. python 安装 Selenium

    2023-12-25 03:32:02       41 阅读
  9. c# opencv 获取多边形中心点

    2023-12-25 03:32:02       38 阅读
  10. ubuntu22.04 安装vscode

    2023-12-25 03:32:02       44 阅读
  11. Unity内置的四种渲染管线简介

    2023-12-25 03:32:02       45 阅读