要安装ULTIMATE版本,并导入key

http://idea.iteblog.com/key.php

安装完成后

1:首先打开New Project
2:选择Spring Initializr 这里直接按Next
3:配置Metadata
Group:com.example
Arifact:demo|
这里直接按Next
4:勾选Web、MyBatis、MySQL然后Next

编辑文件application.properties,添加服务端口、数据库配置

server.port=8081
server.address=0.0.0.0 spring.datasource.url=jdbc:mysql://mysql.feieryun.cn/firadio_yun?verifyServerCertificate=false&useSSL=false
spring.datasource.username=feieryun
spring.datasource.password=feieryun

在DemoApplication.java的同级文件夹
也就是在\demo\src\main\java\com\example\demo下面
新建文件夹controller,然后在里面新建IndexController.java

package com.feieryun.ssproxy.controller;

import com.feieryun.ssproxy.model.bootstrapt.BaseResult;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController; @RestController
public class IndexController {
@RequestMapping(value = {"/"}, method = RequestMethod.GET)
public BaseResult index() {
return new BaseResult(false, "Hello World!", false);
}
}

这个是BaseResult

package com.feieryun.ssproxy.model.bootstrapt;

import java.io.Serializable;

/**
*/
public class BaseResult implements Serializable { //private static final long serialVersionUID = -5231857415211397573L;
private boolean success;
private String msg;
private Object data; public BaseResult() {
} public BaseResult(boolean success, String msg, Object data) {
this.success = success;
this.msg = msg;
this.data = data;
} public boolean isSuccess() {
return success;
} public void setSuccess(boolean success) {
this.success = success;
} public Object getData() {
return data;
} public void setData(Object data) {
this.data = data;
} public String getMsg() {
return msg;
} public void setMsg(String msg) {
this.msg = msg;
}
}

这里是DatabaseConfig的内容

package com.example.demo;

import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.SqlSessionTemplate;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.transaction.annotation.TransactionManagementConfigurer; import javax.sql.DataSource; @Configuration
@EnableTransactionManagement
@MapperScan(basePackages = "com.example.demo.mapper")
public class DatabaseConfig implements TransactionManagementConfigurer { @Autowired
DataSource dataSource; @Bean
public SqlSessionFactory sqlSessionFactory() throws Exception {
SqlSessionFactoryBean sqlSessionFactory = new SqlSessionFactoryBean();
sqlSessionFactory.setDataSource(dataSource);
sqlSessionFactory.setFailFast(true);
return sqlSessionFactory.getObject();
} @Bean
public SqlSessionTemplate sqlSessionTemplate(SqlSessionFactory sqlSessionFactory) {
return new SqlSessionTemplate(sqlSessionFactory);
} /**
* @fun 配置事务管理器
*/
@Bean
@Override
public PlatformTransactionManager annotationDrivenTransactionManager() {
return new DataSourceTransactionManager(dataSource);
} }

用IntelliJ的IDEA来创建SpringBoot框架的更多相关文章

  1. springboot入门(一)--快速搭建一个springboot框架

    原文出处 前言在开始之前先简单介绍一下springboot,springboot作为一个微框架,它本身并不提供Spring框架的核心特性以及扩展功能,只是用于快速.敏捷地开发新一代基于Spring框架 ...

  2. JAVA - 创建SpringBoot项目

    JAVA - 创建SpringBoot项目 Spring Boot是由Pivotal团队提供的全新框架,设计目的是用来简化新Spring应用的初始搭建以及开发过程.它主要推崇的是'消灭配置’,实现零配 ...

  3. SpringBoot框架:快速入门搭建运行一个应用程序(一)

    一.环境配置 Java环境:1.8版本 开发工具:IntelliJ IDEA 二.简单应用 1.创建项目 选择创建的项目类型为Spring Initializr,Project SDK选择1.8版本的 ...

  4. 使用intellij idea搭建MAVEN+springmvc+mybatis框架

    原文:使用intellij idea搭建MAVEN+springmvc+mybatis框架 1.首先使用idea创建一个maven项目 2.接着配置pom.xml,以下为我的配置 <projec ...

  5. SpringBoot01 InteliJ IDEA安装、Maven配置、创建SpringBoot项目、属性配置、多环境配置

    1 InteliJ IDEA 安装 下载地址:点击前往 注意:需要下载专业版本的,注册码在网上随便搜一个就行啦 2 MAVEN工具的安装 2.1 获取安装包 下载地址:点击前往 2.2 安装过程 到官 ...

  6. Springboot 框架学习

    Springboot 框架学习 前言 Spring Boot是Spring 官方的顶级项目之一,她的其他小伙伴还有Spring Cloud.Spring Framework.Spring Data等等 ...

  7. 用IntelliJ IDEA 开发Spring+SpringMVC+Mybatis框架 分步搭建三:配置spring并测试

    这一部分的主要目的是 配置spring-service.xml  也就是配置spring  并测试service层 是否配置成功 用IntelliJ IDEA 开发Spring+SpringMVC+M ...

  8. 用IntelliJ IDEA 开发Spring+SpringMVC+Mybatis框架 分步搭建二:配置MyBatis 并测试(2 配置spring-dao和测试)

    用IntelliJ IDEA 开发Spring+SpringMVC+Mybatis框架 分步搭建二:配置MyBatis 并测试(1 搭建目录环境和依赖) 四:在\resources\spring 下面 ...

  9. 用IntelliJ IDEA 开发Spring+SpringMVC+Mybatis框架 分步搭建一:建立MAVEN Web项目

    一:创建maven web项目er

随机推荐

  1. 【spring源码分析】BeanDefinitionRegistryPostProcessor解析

    一.自定义BeanDefinitionRegistryPostProcessor BeanDefinitionRegistryPostProcessor继承自BeanFactoryPostProces ...

  2. 安装Centos7时提示 /dev/root does not exits

    安装centos 7时提示 "Warning: /dev/root does not exist, could not boot" 这个问题是木有找到你的U盘. 在一个能够编辑U盘 ...

  3. C++中的const关键字学习笔记

    一.const引用 1. 例子一 #include <iostream> using namespace std; class sp { public: sp() {cout<< ...

  4. 列表(list)的增删改查

    list 可以通过 索引,切片,切片加步长取出列表中的某个元素 列表的增: # 追加 append() 在列表的后面追加元素 #  插入 insert()在列表的某个位置插入元素  会加在你输入位置的 ...

  5. IntelliJ IDEA使用心得

    前言:我原来一直使用的是Eclipse,但是发现有的教程上使用的是Intellij这个IDE,而且我发现Eclipse在Web编程上特别是页面上的自动补全上确实有些不足,而且Intellij这个软件的 ...

  6. Hiero_FnNukeShotExporter的解析与修改

    研究对象:Hiero中的FnNukeShotExporter脚本 研究目的:修改FnNukeShotExporter使得可以将多个TrackItem导入到一个.nk中   FnNukeShotExpo ...

  7. hadoop HA分布式集群搭建

    概述 hadoop2中NameNode可以有多个(目前只支持2个).每一个都有相同的职能.一个是active状态的,一个是standby状态的.当集群运行时,只有active状态的NameNode是正 ...

  8. Action<T> Delegate

    来源:https://docs.microsoft.com/zh-cn/dotnet/api/system.action-1?view=netframework-4.7.2 Action<T&g ...

  9. Windows Azure Virtual Machine (35) Azure VM通过Linked DB,执行SQL Job

    <Windows Azure Platform 系列文章目录> 今天遇到一个Case,客户在使用Azure Automation,执行Azure SQL Database 存储过程的时候, ...

  10. php 二维数组按照指定字段进行排序

    $allItem = [ ["id"=>10,"updated_at"=>"2018-11-01"], ["id&qu ...