springboot 环境搭建

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 http://maven.apache.org/xsd/maven-4.0.0.xsd">    <modelVersion>4.0.0</modelVersion>    <groupId>com.liuqd.springboot</groupId>    <artifactId>springboot</artifactId>    <version>1.0-SNAPSHOT</version>    <packaging>war</packaging>         <parent>                <groupId>org.springframework.boot</groupId>                <artifactId>spring-boot-starter-parent</artifactId>                <version>1.5.6.RELEASE</version>         </parent>        <properties>            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>            <spring.boot.version>1.5.6.RELEASE</spring.boot.version>            <thymeleaf.version>3.0.2.RELEASE</thymeleaf.version>            <thymeleaf-layout-dialect.version>2.2.1</thymeleaf-layout-dialect.version>        </properties>        <dependencyManagement>            <dependencies>                <dependency>                    <groupId>org.springframework</groupId>                    <artifactId>spring-framework-bom</artifactId>                    <version>4.3.1.RELEASE</version>                    <type>pom</type>                    <scope>import</scope>                </dependency>            </dependencies>        </dependencyManagement>        <dependencies>            <dependency>                <groupId>org.springframework.boot</groupId>                <artifactId>spring-boot-starter-web</artifactId>                <version>${spring.boot.version}</version>            </dependency>            <dependency>                <groupId>org.springframework.boot</groupId>                <artifactId>spring-boot-starter-actuator</artifactId>                <version>${spring.boot.version}</version>            </dependency>            <!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-data-jpa -->            <dependency>                <groupId>org.springframework.boot</groupId>                <artifactId>spring-boot-starter-data-jpa</artifactId>                <version>${spring.boot.version}</version>            </dependency>            <!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-thymeleaf -->            <dependency>                <groupId>org.springframework.boot</groupId>                <artifactId>spring-boot-starter-thymeleaf</artifactId>                <version>${spring.boot.version}</version>            </dependency>            <!-- https://mvnrepository.com/artifact/org.thymeleaf/thymeleaf -->            <dependency>                <groupId>org.thymeleaf</groupId>                <artifactId>thymeleaf</artifactId>                <version>${thymeleaf.version}</version>            </dependency>            <dependency>                <groupId>org.apache.tomcat.embed</groupId>                <artifactId>tomcat-embed-jasper</artifactId>                <scope>provided</scope>            </dependency>            <!-- https://mvnrepository.com/artifact/org.thymeleaf/thymeleaf-spring4 -->            <dependency>                <groupId>org.thymeleaf</groupId>                <artifactId>thymeleaf-spring4</artifactId>                <version>${thymeleaf.version}</version>            </dependency>

<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->            <!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->            <dependency>                <groupId>mysql</groupId>                <artifactId>mysql-connector-java</artifactId>                <version>5.0.2</version>            </dependency>

</dependencies>

<build>            <plugins>                <plugin>                    <groupId>org.apache.maven.plugins</groupId>                    <artifactId>maven-surefire-plugin</artifactId>                    <version>2.4.2</version>                    <configuration>                        <skipTests>true</skipTests>                    </configuration>                </plugin>

</plugins>        </build>

</project>
/** * Created by who on 16-7-16. */@Configuration@Import(WebMvcAutoConfiguration.WebMvcAutoConfigurationAdapter.class)public class WebMvcConfig {

@Configuration    @EnableWebMvc    @EnableConfigurationProperties({ThymeleafProperties.class})    public static class ThymeleafAutoConfiguration extends WebMvcConfigurerAdapter {        @Autowired        private ApplicationContext applicationContext;        @Autowired        private ThymeleafProperties thymeleafProperties;       /** @Override        public void addViewControllers(ViewControllerRegistry registry) {            //registry.addViewController("/home").setViewName("home");           // registry.addViewController("/").setViewName("hello");            //registry.addViewController("/hello").setViewName("hello");            //registry.addViewController("/login").setViewName("login");        }*/        @Bean        public ITemplateResolver templateResolver() {            SpringResourceTemplateResolver templateResolver = new SpringResourceTemplateResolver();            templateResolver.setApplicationContext(applicationContext);            templateResolver.setPrefix(thymeleafProperties.getPrefix());            templateResolver.setSuffix(thymeleafProperties.getSuffix());            templateResolver.setTemplateMode(TemplateMode.HTML);            templateResolver.setCacheable(thymeleafProperties.isCache());

if (thymeleafProperties.getEncoding() != null) {                templateResolver.setCharacterEncoding(thymeleafProperties.getEncoding().name());            }

if (thymeleafProperties.getTemplateResolverOrder() != null) {                templateResolver.setOrder(thymeleafProperties.getTemplateResolverOrder());            }

return templateResolver;        }

@Bean        public TemplateEngine templateEngine(ITemplateResolver templateResolver) {            SpringTemplateEngine engine = new SpringTemplateEngine();            engine.setEnableSpringELCompiler(true);            engine.setTemplateResolver(templateResolver);            return engine;        }

@Bean        public ViewResolver viewResolver(ITemplateEngine templateEngine) {            ThymeleafViewResolver resolver = new ThymeleafViewResolver();            resolver.setTemplateEngine(templateEngine);            resolver.setCharacterEncoding(thymeleafProperties.getEncoding().name());            resolver.setContentType(appendCharset(this.thymeleafProperties.getContentType(), resolver.getCharacterEncoding()));            resolver.setExcludedViewNames(this.thymeleafProperties.getExcludedViewNames());            resolver.setViewNames(this.thymeleafProperties.getViewNames());            resolver.setOrder(Ordered.LOWEST_PRECEDENCE - 5);            resolver.setCache(thymeleafProperties.isCache());            return resolver;        }/****/        private String appendCharset(MimeType type, String charset) {            if (type.getCharset() != null) {                return type.toString();            }            LinkedHashMap<String, String> parameters = new LinkedHashMap<String, String>();            parameters.put("charset", charset);            parameters.putAll(type.getParameters());            return new MimeType(type, parameters).toString();        }    }

// ****************** druid monitor    // access url /druid/index.html    /**    @Bean    public ServletRegistrationBean druidServlet() {        return new ServletRegistrationBean(new StatViewServlet(), "/druid/*");    }

@Bean    public FilterRegistrationBean filterRegistrationBean() {        FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();        filterRegistrationBean.setFilter(new WebStatFilter());        filterRegistrationBean.addUrlPatterns("/*");        filterRegistrationBean.addInitParameter("exclusions", "*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*");        return filterRegistrationBean;    }**/}
@SpringBootApplication(scanBasePackages = {"com"},        exclude = {org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration.class})
时间: 2024-08-08 00:17:39

springboot 环境搭建的相关文章

SpringBoot环境搭建?

1.创建Maven工程. 2.添加SpringBoot起步依赖. SpringBoot要求,项目要继承SpringBoot的起步依赖spring-boot-starter-parent,所以我们在pom.xml中添加下面的代码: <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <v

Spring cloud微服务安全实战-7-11PinPoint+SpringBoot环境搭建

微服务的最后一个组件, 调用链监控,一个请求进来以后,经过N多个微服务,例如a调用了b.b又调用了c,那么在这个过程中看到,整个的调用的链路,然后每一段调用所耗费的时间,帮你去分析你的系统如果出现瓶颈以后,瓶颈到底在什么地方. pinpoint 点击看一下在线的demo 提供的一些应用的列表 选择order.这张图就是order这个服务的调用图. 出去调用的一层,分别调用了product和payment还有mysql数据库 outbound选择两层的话 图就会刷新.每一个箭头上都有数字,数字就是

idea开发之springboot环境搭建

1.新建maven工程 2.在pom文件中引入SpringBoot相关依赖 <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.5.1.RELEASE</version> </parent> <dependencies>

SpringBoot环境搭建及第一个程序运行(详细!)

前言 SpringBoot早就想好好学习一下了,奈何自己水平不够在ssm卡了很久,好在前几天写完了一个SSM项目发到阿里云上了,网址在这贴一下,觉得还可以就往下学新的框架了,其实有了SpringMVC的底子学习过程还是很快的,记录一下学习的全过程,这样以后忘了的知识点也方便查缺补漏,话不多说直接上干货. spring boot简介 spring boot框架抛弃了繁琐的xml配置过程,采用大量的默认配置简化我们的开发过程. 所以采用Spring boot可以非常容易和快速地创建基于Spring

spring-boot环境搭建

1.下载:spring-tool-suite-3.9.2.RELEASE-e4.7.2-win32-x86_64http://spring.io/tools/sts/all解压后点击 配置Maven 新建项目:输入项目名称: 输入web显示成功: 新建类: 类里编写: import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestC

SpringBoot学习(一)--环境搭建

1. 什么是SpringBoot? Spring Boot 是由 Pivotal 团队提供的全新框架,其设计目的是用来简化新 Spring 应用的初始搭建以及开发过程.该框架使用了特定的方式来进行配置,从而使开发人员不再需要定义样板化的配置.通过这种方式,Spring Boot 致力于在蓬勃发展的快速应用开发领域(rapidapplication development)成为领导者.–摘自百度百科 2. 为什么现在用SpringBoot? 1. 创建独立的 Spring 应用程序 2. 嵌入的

一、springBoot简介与环境搭建

前言:学习计划 1.springBoot环境搭建 2.springBoot入门 3.srpingBoot整合Mybatis 4.springBoot整合Redis,Redis集群 5.springBoot简单综合案例 一.springBoot简介 Spring Boot是由Pivotal团队提供的全新框架,其设计目的是用来简化新Spring应用的初始搭建以及开发过程.该框架使用了特定的方式来进行配置(约定优于配置),从而使开发人员不再需要定义样板化的配置.通过这种方式,Spring Boot致力

Springboot学习记录1--概念介绍以及环境搭建

摘要:springboot学习记录,环境搭建: 官方文档地址:https://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/ 本机为Ubuntu 概念:Spring Boot是由Pivotal团队提供的全新框架,其设计目的是用来简化新Spring应用的初始搭建以及开发过程.该框架使用了特定的方式来进行配置,从而使开发人员不再需要定义样板化的配置.通过这种方式,Spring Boot致力于在蓬勃发展的快速

小编带您进入SpringBoot (1) idea下的环境搭建及demo

1.Spring Boot简介wiki上的介绍: Spring Boot是Spring的常规配置解决方案,用于创建可以"运行"的独立的,生产级的基于Spring的应用程序.[22]它预先配置了Spring对Spring平台和第三方库的最佳配置和使用的"见解视图",因此您可以尽量少开始.大多数Spring Boot应用程序只需要很少的Spring配置.特征: 创建独立的Spring应用程序直接嵌入Tomcat或Jetty(无需部署WAR文件)提供自以为是的"