Intellij idea + Spring boot + Thymeleaf + MySQL
来源:互联网 发布:网络调研公司 编辑:程序博客网 时间:2024/05/22 04:40
1.版本
1.Intellij idea 2016.2.4 +;
2.Spring boot 1.3.8;
3.MySQL 5.6 +;
2.maven 配置
<!-- use a later Java version --><properties> <java.version>1.8</java.version> <!-- use a later Java version --></properties>
<!-- Inherit defaults from Spring Boot --><parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.3.8.RELEASE</version></parent>
<!-- Add typical dependencies for a web application --><dependencies><dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId> <exclusions> <exclusion> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> </exclusion> </exclusions></dependency><dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-undertow</artifactId></dependency><dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter</artifactId></dependency><dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-jdbc</artifactId></dependency><dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> <exclusions> <exclusion> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-logging</artifactId> </exclusion> </exclusions></dependency><dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId></dependency><!-- Developer tools --><dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId></dependency></dependencies><repositories> <repository> <id>spring-milestone</id> <url>https://repo.spring.io/libs-release</url> </repository></repositories><pluginRepositories> <pluginRepository> <id>spring-milestone</id> <url>https://repo.spring.io/libs-release</url> </pluginRepository></pluginRepositories>3.Application 启动类
@Configuration@EnableAutoConfiguration@ComponentScanpublic class Application { private final Logger log = LoggerFactory.getLogger(Application.class); public static void main(String[] args) { SpringApplication.run(Application.class, args); }}
4.application.properties 配置
multipart.max-request-size=100MBmultipart.max-file-size=100MBinfo.build.artifactId=@project.artifactId@info.build.version=@project.version@# LOGGINGlogging.file=isy.loglogging.path=logsserver.undertow.accesslog.dir=logsserver.undertow.accesslog.enabled=truespring.devtools.livereload.enabled=truespring.devtools.restart.enabled=truespring.datasource.url=jdbc:mysql://localhost/isy?useUnicode=true&characterEncoding=utf-8&useSSL=falsespring.datasource.username=rootspring.datasource.password=123456spring.datasource.driver-class-name=com.mysql.jdbc.Driverspring.datasource.schema=isy# Number of ms to wait before throwing an exception if no connection is available.spring.datasource.max-wait=10000# Maximum number of active connections that can be allocated from this pool at the same time.spring.datasource.max-active=50spring.datasource.max-idle=50# Validate the connection before borrowing it from the pool.spring.datasource.test-on-borrow=truespring.datasource.validation-query=select 1;server.port = 8443server.context-path=spring.resources.chain.strategy.content.enabled=truespring.resources.chain.strategy.content.paths=/**5.说明
1.一般Application.java 是在你建的包最顶层,如我的在top.zbeboy.isy 下方,其余包都在top.zbeboy.isy下,如 top.zbeboy.isy.services,top.zbeboy.isy.domain等等,这样启动时才能扫描到注解等等。2.application.properties据官方文档解释有三种方式,其中一种是扫描根目录,因此放在resources目录下即可。3.Intellij idea热加载方式是需要ctrl+F9来重新编译下才可,但有时还是会有问题,比如重新加载后丢失spring 创建的对象而报错,一般不改或增加注解没什么问题。4.这里没有使用tomcat 而是 undertow,官方默认是tomcat,我这里是按照生产环境配置的,当然application.properties也可以配置成application-*.properties使用profile来切换环境,这里的示例是简单配置。5.启动类里我没有使用@SpringBootAutoConfiger,这样便于后期加缓存,spring security等,你也可以使用该方式简化配置。6.在生产环境里应该将配置文件中的devtools设置为false。到 github:ISY 查看更多高级配置。
0 0
- Intellij idea + Spring boot + Thymeleaf + MySQL
- intellij idea + spring boot + mybatis + druid + maven + mysql + thymeleaf
- intellij idea + spring boot + spring data jpa + druid + maven + mysql + thymeleaf
- Intellij Idea spring boot 报错记录
- Spring Boot + Intellij IDEA 热部署
- IntelliJ IDEA + Spring Boot + Mybatis的整合
- Intellij IDEA 学习Spring Boot (1)
- [spring-boot] thymeleaf 热交换
- Spring Boot + Gradle + Thymeleaf
- spring boot 整合 thymeleaf
- spring boot vue Thymeleaf
- spring boot thymeleaf 用法
- Spring Boot使用Thymeleaf
- Spring-Boot thymeleaf异常
- spring-boot集成thymeleaf
- Spring Boot整合thymeleaf
- IntelliJ Idea 实现热部署 Spring Loaded spring-boot-devtools
- Spring Boot+Spring Security+Thymeleaf
- java中JVM的原理
- iOS添加虚线边框
- bzoj4196: [Noi2015]软件包管理器
- printf类型简易说明
- 2016.11.11 jq(复习1 选择器 事件 效果)
- Intellij idea + Spring boot + Thymeleaf + MySQL
- 关于Spring事务<tx:annotation-driven/>的理解(Controller可以使用@Transactional)
- LeetCode 452. Minimum Number of Arrows to Burst Balloons
- css3实现六边形列表
- Android多文件断点续传(二)——实现数据库储存下载信息
- 关于IOS 高德地图的一些问题
- C++文件读写详解(ofstream,ifstream,fstream)
- mybatis在xml文件中处理大于号小于号的方法
- QT 利用QPainter绘图的坐标系转换