maven仓库管理,创建一个简单的springboot项目,hello springboot

1.开发准备

1.1 springboot的简单介绍:

使用框架可以帮助我们提高开发的速度,因为它已经封装好了很多东西,我们只要会用框架提供给我们的使用规则就行了!

springboot相当于一种配置简化了的SSM框架,而且springboot配置及其简单!

1.2 环境介绍:JDK1.8tomcat8.0(这不重要。。。

2.开整

2.1 新建一个maven项目:

2.2 按图勾选---next

2.3 填写项目名称等---finish

2.4 打开porm.xml

将下列代码复制过去(你的版本信息换成自己的)

<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<groupId>com.nuist</groupId>
	<artifactId>springboot</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<name>springboot</name>
	<description>springboot</description>
   
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.9.RELEASE</version>
    </parent>
 
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
              <groupId>junit</groupId>
              <artifactId>junit</artifactId>
              <version>3.8.1</version>
              <scope>test</scope>
        </dependency>
    </dependencies>
 
    <properties>
        <java.version>1.8</java.version>
    </properties>
 
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
 
</project>

2.5 右键单击项目--maven--update project(联网状态下会下载porm.xml中配置的包)

2.6 新建两个个包:com.nuist.controller

com.nuist.web

2.7 然后在springboot包(没有则创建一个)下新建一个类叫Application.java

写入代码:

如果像我这样报错,鼠标放到错误的地方,点击import*****

错误就好解决,然后保存!

2.8 在controller包下新建一个类:

在类中写入如下代码:

2.9 然后回到Applocation.java,右键--run as --java application

2.10 一般来说会直接运行成功

在浏览器输入http://127.0.0.1:8080/hello

我们就会看到

hello sweety

的字样!

2.11 如果遇到这种错误:

那是因为端口8080被占用,需要“杀掉”占用此端口的进程:

***打开cmd,

***输入netstat -ano                

(查看8080被谁占用了,记住端口号pid)

***输入taskkill /t /f /pid 9534

(9534是占用端口的进程)

***回到项目中,重新run

3.

结果:还是出错了!

但是我们要知道,报这个错应该不是程序写的有问题,因该是结构有问题,导致不能正确访问!

下一篇文章教你们解决!

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
可以按照以下步骤在IDEA中使用Maven创建Spring Boot项目: 1. 打开IDEA,点击 “Create New Project” 选择 Maven 并点击 “Next”。 2. 输入 GroupId、ArtifactId 和版本号,然后选择 “Create from archetype” 并选择 “org.apache.maven.archetypes:maven-archetype-quickstart”。 3. 在下一步中,可以自定义项目名称和路径。 4. 在下一步中,可以选择项目的 JDK 版本、默认的包等信息。 5. 在下一步中,可以进一步配置 Maven 项目的选项,如指定 Maven 版本、本地仓库位置、代理设置等。 6. 点击 “Finish” 完成创建项目。 接下来,我们需要进行以下步骤来将创建Maven 项目转换为 Spring Boot 项目: 1. 在项目的 pom.xml 文件中,添加 Spring Boot 的依赖,例如: ``` <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <version>2.5.2</version> </dependency> ``` 2. 在项目中添加 Spring Boot 的启动类,例如: ``` @SpringBootApplication public class MyApplication { public static void main(String[] args) { SpringApplication.run(MyApplication.class, args); } } ``` 3. 编写 Spring Boot 的业务代码,例如: ``` @RestController public class MyController { @GetMapping("/hello") public String hello() { return "Hello, World!"; } } ``` 4. 启动 Spring Boot 项目,可以通过运行启动类中的 main 方法或者使用 Maven 插件来进行启动。 以上就是在 IDEA 中使用 Maven 创建 Spring Boot 项目的基本步骤。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值