• Intellij idea 新建springboot 项目


    Intellij idea 安装

    下载2021.2版本,

    下载FineAgent.jar 修改

    C:UsersOwnerAppDataRoamingJetBrainsIntelliJIdea2021.2idea64.exe.vmoptions

    在尾部加入(把文件拷贝到C盘根目录)

    -javaagent:C:\FineAgent.jar

    运行压缩包里的.vbs 文件,重启ide,输入激活码。


    新建springboot项目

    右键main,新建文件夹,命名webapp,里面放jsp文件

    配置运行参数

    修改yml文件

    spring:
      datasource:
        type:  com.alibaba.druid.pool.DruidDataSource
        druid:
          driver-class-name: com.mysql.cj.jdbc.Driver
          url: jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai
          username: root
          password: xxxxx
          initial-size: 1
          min-idle: 1
          max-active: 50
          max-wait: 15000
          enable: true
          test-on-borrow: true
          test-on-return: true
          test-while-idle: true
      mvc:
        view:
          suffix: .jsp
          #prefix: /WEB-INF/jsp/
          prefix: /
    
    mybatis:
      mapper-locations:
        - classpath:mapper/*Mapper.xml
         #这个需要指出,否则不会加载mapper.xml文件

    修改pom文件

    <?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>
        <parent>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-parent</artifactId>
            <version>2.5.4</version>
            <relativePath/> <!-- lookup parent from repository -->
        </parent>
        <groupId>com.example</groupId>
        <artifactId>demo</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <name>demo</name>
        <description>demo</description>
        <properties>
            <java.version>1.8</java.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.0</version>
            </dependency>
    
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-devtools</artifactId>
                <scope>runtime</scope>
                <optional>true</optional>
            </dependency>
            <dependency>
                <groupId>mysql</groupId>
                <artifactId>mysql-connector-java</artifactId>
                <scope>runtime</scope>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-configuration-processor</artifactId>
                <optional>true</optional>
            </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>
    
            <dependency>
                <groupId>com.alibaba</groupId>
                <artifactId>druid-spring-boot-starter</artifactId>
                <version>1.2.4</version>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-jdbc</artifactId>
                <!-- <version>2.4.2</version> -->
            </dependency>
            <dependency>
                <groupId>org.apache.tomcat.embed</groupId>
                <artifactId>tomcat-embed-jasper</artifactId>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-tomcat</artifactId>
    
            </dependency>
    
            <dependency>
                <groupId>javax.servlet</groupId>
                <artifactId>javax.servlet-api</artifactId>
                <scope>provided</scope>
            </dependency>
            <!--jsp依赖的jar包 -->
            <!-- https://mvnrepository.com/artifact/javax.servlet.jsp/javax.servlet.jsp-api -->
            <dependency>
                <groupId>javax.servlet.jsp</groupId>
                <artifactId>javax.servlet.jsp-api</artifactId>
                <version>2.3.1</version>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>javax.servlet</groupId>
                <artifactId>jstl</artifactId>
            </dependency>
    
        </dependencies>
    
        <build>
            <resources>
                <resource>
                    <directory>src/main/resources</directory>
                    <filtering>false</filtering>
                </resource>
                <resource>
                    <directory>src/main/webapp</directory>
                    <!--  注意此次必须要放在此目录下才能被访问到 -->
                    <targetPath>META-INF/resources</targetPath>
                    <includes>
                        <include>**/**</include>
                    </includes>
                </resource>
            </resources>
            <plugins>
                <plugin>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId> 
             
     <!-- 必须加版本号,否则打包后,找不到jsp文件 -->
    <version>1.4.2.RELEASE</version> <configuration> <excludes> <exclude> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> </exclude> </excludes> </configuration> </plugin> </plugins> </build> </project>
  • 相关阅读:
    java——多线程——Thread类的常用方法——sleep
    java——多线程——进程的理解
    java——多线程——主线程的概念
    java 一个对象的内存图
    Vue实现鼠标拖拽滚动效果,滚动方向不同控制不同组件滚动自定义指令
    uniapp封装axios
    移动端经典布局左边导航右边滚动列表
    uniapp将盒子铺满页面,适应导航栏高度,无滚动条
    vue/uniapp 用键值对的形式动态控制class,事先导航栏效果
    Vue新建项目
  • 原文地址:https://www.cnblogs.com/sdgtxuyong/p/15176659.html
Copyright © 2020-2023  润新知