环境:jdk1.8 + maven+idea

1:首先我们在idea上创建一个springboot的项目。

 2:我这里的java version选择的是8

 3:先勾选一个spring web

 4:先编写一个Controller类,在测试我们的springboot能正常运行

5: 默认端口是8080,在浏览器上访问我们@RequestMapping上的地址,看是否能返回我们定义的字段

 6:在pom.xml导入我们需要的maven依赖

 <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.0.0</version>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>8.0.19</version>
        </dependency>
        <dependency>
            <groupId>org.thymeleaf</groupId>
            <artifactId>thymeleaf-spring5</artifactId>
        </dependency>
        <dependency>
            <groupId>org.thymeleaf.extras</groupId>
            <artifactId>thymeleaf-extras-java8time</artifactId>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.16.10</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>
        <dependency>
            <groupId>net.sourceforge.nekohtml</groupId>
            <artifactId>nekohtml</artifactId>
            <version>1.9.22</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>

        </plugins>
    </build>

</project>

6: 我们导入了lombok依赖,我们就可以在实体类中不用手动去添加get set 构造器,可以用标签代替了

7:在resources目录下建两个包,把们的静态资源放在templates目录下,将我们的css文件放在static目录下

  8:我们发现index.html是我们的登录页面,所以说我们要将index.html页面作为默认的跳转页面

 

 9:需要我们实现WebMvcConfigurer接口中的addViewControllers方法来实现

 

 10:我们就要开始做登录功能了,登录其实就是查询,前端输入账号密码然后传到我们controller层在传到我们的service层在到我们的mapper层如果账号密码正确就有返回对象,如果没有这返回null,我们先配置数据库并建一个user表

 

 

 

 

 

 

 

 

 拦截器

 

 后面还有展示员工,修改员工,添加员工,删除员工说白了就是增删除改查这些功能可以自己实现,我我可以把这个项目的文件发给你们

需要的话+qq 1421468941

 

 

 

 

 

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐