SpringBoot+ general Mapper+Thymeleaf+Bootstrap integration and encountered problems

Pom. XML:

It depends on the configuration of the JAR package

<dependencies> <! -- Web dependency --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <! <dependency> <groupId>org.mybatis.spring. Boot </groupId> < artifactId > mybatis - spring - the boot - starter < / artifactId > < version > 2.1.4 < / version > < / dependency > <! <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> The < version > 5.1.32 < / version > < scope > runtime < / scope > < / dependency > <! -- Unit test dependency --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> <! Mapper --> <dependency> <groupId>tk.mybatis</groupId> <artifactId>mapper-spring-boot-starter</artifactId> The < version > 2.0.2 < / version > < / dependency > <! --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId> </dependency> </dependencies> 123456789101112131415161718192021222324252627282930313233343536373839404142Copy the code

Application. Yml file configuration:

The jar package of mysql5.1.32 is imported here so the old package name is still written

Spring: # datasource: # com.mysql.cj.jdbc.driver driver-class-name: # datasource: # com.mysql.cj.jdbc.driver #. Com. Mysql. JDBC Driver version of mysql need to set the time zone: & serverTimezone = GMT url: JDBC: mysql: / / localhost: 3306 / springboot? UseUnicode =true&characterEncoding=utf8 username: root password: root #thymeleaf classpath:/templates/ suffix: .html encoding: utf-8 mode: HTML5 servlet: content-type: /static/** #mybatis: /static/** #mybatis: Type -aliases-package: com.example.domain MYSQL 1234567891011121314151617181920212223242526272829303132Copy the code

Major problems encountered:

The static resources imported locally on the login. HTML page cannot be accessed



The login. HTML page imports local static resources

<link rel="stylesheet" href=".. /static/css/bootstrap.min.css" th:href="@{/css/bootstrap.min.css}"> <script src=".. /static/js/bootstrap.min.js" th:src="@{/js/bootstrap.min.js}"></script> <script src=".. / static/js/jquery - 3.2.1. Min. Js "th: SRC =" @ {/ js/jquery - 3.2.1. Min. Js} "> < / script > 123Copy the code

After importing static resources, you must Rebuild them. Otherwise, static resources cannot be loaded.

Thank you for reading here, the article is inadequate, welcome to point out; If you think it’s good, give me a thumbs up.

Also welcome to pay attention to my public number: Java programmers gathering place, Maidong will share Java related technical articles or industry information every day, welcome to pay attention to and forward the article!