创建SpringBoot的一些基本配置信息

  • 基础配置

    创建maven-archetype-quickstart 或 spring starter project(在线的,需要插件) 创建时mybatis mysql spring web 设置这几个

    • 在resources中创建static 存放静态页面 (外部可以直接访问)
    • 在resources中创建templates 存放控制器跳转页面
    • 基本文件common下,config,controller,dao,domain(entity),service(biz),utils,userrealm,quartz,redis
    • 配置springboot,要创建applicationi.properties 文件:
 #控制器跳转页面默认前缀
        spring.mvc.view.prefix=/WEB-INF/ 
         #控制器跳转页面默认前缀
        spring.mvc.view.suffix=.jsp      
        
        #mybatis的配置
        mybatis.mapper-locations:classpath:/mapper/*.xml
        
        #数据源配置
        spring.datasource.url=jdbc:mysql://localhost:3306/shop1905
        spring.datasource.username=root
        spring.datasource.password=19980220
        spring.datasource.driver-class-name=com.mysql.jdbc.Driver
        spring.datasource.type=com.alibaba.druid.pool.DruidDataSource

配置springboot,也可创建application.yml(有提示补全功能):

    server:
      port: 80
    debug: false
    spring:
      datasource:
        url: jdbc:mysql://localhost:3306/shop1905  #自己数据库表的路径
        driver-class-name: com.mysql.jdbc.Driver
        password: 数据库的密码
        username: 数据库的账户名
        type: com.alibaba.druid.pool.DruidDataSource
      mvc:       # 控制器跳转页面不放在templates,而是src/main/webapp/WEB-INF/下
        view:
          suffix: .jsp
          prefix: /WEB-INF/
        
    mybatis:
      mapper-locations:
      - classpath:/mapper/*.xml  

启动web的类

    @SpringBootApplication  //必须加这个注解
    @ComponentScan("com.octopus") //扫描控制器,默认扫描是此文件的包旗下所有类
    @MapperScan("com.octopus.dao")
    public class App 
    {
        public static void main( String[] args )
        {
        	SpringApplication.run(App.class);
            System.out.println( "Hello World!" );
        }
    }

//在pom.xml添加继承

    <parent>
    		<groupId>org.springframework.boot</groupId>
    		<artifactId>spring-boot-starter-parent</artifactId>
    		<version>2.2.4.RELEASE</version>
    		<relativePath />
    	</parent>

要实现可以打包的功能 需在x在pom.xm中加入

    <build>
    		<plugins>
    			<plugin>
    				<groupId>org.springframework.boot</groupId>
    				<artifactId>spring-boot-maven-plugin</artifactId>
    			</plugin>
    		</plugins>
    	</build>
  • java -jar xxx.jar(此打包) 即可开启浏览器访问 (设备需要有兼容的jdk即可访问)

  • 也可解压以后 java org.springframework.boot.loader.JarLauncher (target里)

  • 服务器的动态文件都在classes里 可以单个替换实现更新 不必全部重搞

  • 所有基本依赖完整标准电商项目的pom.xml

 <?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.octopus</groupId>
<artifactId>eshop_new</artifactId>
<version>1.1.3</version>
<packaging>jar</packaging>

<name>eshop_new</name>
<description>代码基础系统</description>

<parent>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-starter-parent</artifactId>
	<version>2.2.0.RELEASE</version>
	<relativePath />
</parent>

<properties>
	<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
	<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
	<java.version>1.8</java.version>
	<mybatisplus-spring-boot-starter.version>1.0.4</mybatisplus-spring-boot-starter.version>
	<velocity.version>1.7</velocity.version>
</properties>

<dependencies>
	<dependency>
		<groupId>com.gitee.qdbp.thirdparty</groupId>
		<artifactId>ueditor</artifactId>
		<version>1.4.3.3</version>
	</dependency>

	<dependency>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter</artifactId>
	</dependency>

	<dependency>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-test</artifactId>
		<scope>test</scope>
	</dependency>
	<dependency>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-aop</artifactId>
	</dependency>
	<!--web -->
	<dependency>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-web</artifactId>
	</dependency>
	<dependency>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-thymeleaf</artifactId>
	</dependency>
	<dependency>
		<groupId>net.sourceforge.nekohtml</groupId>
		<artifactId>nekohtml</artifactId>
	</dependency>
	<!--mybatis -->
	<dependency>
		<groupId>mysql</groupId>
		<artifactId>mysql-connector-java</artifactId>
	</dependency>
	<dependency>
		<groupId>org.mybatis</groupId>
		<artifactId>mybatis</artifactId>
		<version>3.4.4</version>
	</dependency>

	<dependency>
		<groupId>org.mybatis.spring.boot</groupId>
		<artifactId>mybatis-spring-boot-starter</artifactId>
		<version>1.1.1</version>
	</dependency>
	<!--druid -->
	<dependency>
		<groupId>com.alibaba</groupId>
		<artifactId>druid</artifactId>
		<version>1.0.28</version>
	</dependency>
	<!--commons -->
	<dependency>
		<groupId>org.apache.commons</groupId>
		<artifactId>commons-lang3</artifactId>
	</dependency>
	<dependency>
		<groupId>commons-configuration</groupId>
		<artifactId>commons-configuration</artifactId>
		<version>1.10</version>
	</dependency>
	<dependency>
		<groupId>commons-io</groupId>
		<artifactId>commons-io</artifactId>
		<version>2.5</version>
	</dependency>
	<!--shiro -->
	<dependency>
		<groupId>org.apache.shiro</groupId>
		<artifactId>shiro-spring</artifactId>
		<version>1.4.0</version>
	</dependency>

	<dependency>
		<groupId>com.github.theborakompanioni</groupId>
		<artifactId>thymeleaf-extras-shiro</artifactId>
		<version>2.0.0</version>
	</dependency>
	<!-- utils -->
	<dependency>
		<groupId>com.alibaba</groupId>
		<artifactId>fastjson</artifactId>
		<version>1.2.31</version>
	</dependency>
	<!-- POI -->
	<dependency>
		<groupId>org.apache.poi</groupId>
		<artifactId>poi</artifactId>
		<version>3.8</version>
		<exclusions>
			<exclusion>
				<artifactId>commons-codec</artifactId>
				<groupId>commons-codec</groupId>
			</exclusion>
		</exclusions>
	</dependency>
	<dependency>
		<groupId>org.apache.poi</groupId>
		<artifactId>poi-ooxml</artifactId>
		<version>3.8</version>
	</dependency>
	<!--velocity代码生成使用模板 -->
	<dependency>
		<groupId>org.apache.velocity</groupId>
		<artifactId>velocity</artifactId>
		<version>1.7</version>
	</dependency>
	<!-- ehchache -->
	<dependency>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-cache</artifactId>
	</dependency>
	<dependency>
		<groupId>net.sf.ehcache</groupId>
		<artifactId>ehcache</artifactId>
	</dependency>
<!-- quartz依赖 -->
	<dependency>
		<groupId>org.quartz-scheduler</groupId>
		<artifactId>quartz</artifactId>
		<version>2.2.1</version>
		<exclusions>
			<exclusion>
				<artifactId>slf4j-api</artifactId>
				<groupId>org.slf4j</groupId>
			</exclusion>
		</exclusions>
	</dependency>
	
	<!-- SpringWebSocket依赖 -->
	<dependency>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-websocket</artifactId>
	</dependency>
	<dependency>
		<groupId>org.springframework</groupId>
		<artifactId>spring-context-support</artifactId>
	</dependency>


	<!--swagger2 -->
	<dependency>
		<groupId>io.springfox</groupId>
		<artifactId>springfox-swagger2</artifactId>
		<version>2.6.1</version>
	</dependency>
	<dependency>
		<groupId>io.springfox</groupId>
		<artifactId>springfox-swagger-ui</artifactId>
		<version>2.6.1</version>
	</dependency>

	<!-- 添加redis支持 -->
	<dependency>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-data-redis</artifactId>
	</dependency>

	<!-- xss过滤组件 -->
	<dependency>
		<groupId>org.jsoup</groupId>
		<artifactId>jsoup</artifactId>
		<version>1.9.2</version>
	</dependency>



	<dependency>
		<groupId>org.xhtmlrenderer</groupId>
		<artifactId>flying-saucer-pdf</artifactId>
		<version>9.1.1</version>
	</dependency>
	<dependency>
		<groupId>org.commonjava.googlecode.markdown4j</groupId>
		<artifactId>markdown4j</artifactId>
		<version>2.2-cj-1.0</version>
	</dependency>

	<dependency>
		<groupId>net.sf.jtidy</groupId>
		<artifactId>jtidy</artifactId>
		<version>r938</version>
	</dependency>
	<dependency>
		<groupId>com.itextpdf</groupId>
		<artifactId>html2pdf</artifactId>
		<version>2.1.0</version>
	</dependency>
	<dependency>
		<groupId>com.vladsch.flexmark</groupId>
		<artifactId>flexmark-all</artifactId>
		<version>0.34.38</version>
	</dependency>
	<dependency>
		<groupId>com.googlecode.java-diff-utils</groupId>
		<artifactId>diffutils</artifactId>
		<version>1.3.0</version>
	</dependency>





</dependencies>
<build>
	<plugins>
		<plugin>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-maven-plugin</artifactId>
			<configuration>
				<executable>true</executable>
			</configuration>
		</plugin>
	</plugins>
</build>
<repositories>
	<repository>
		<id>public</id>
		<name>aliyun nexus</name>
		<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
		<releases>
			<enabled>true</enabled>
		</releases>
	</repository>
</repositories>
<pluginRepositories>
	<pluginRepository>
		<id>public</id>
		<name>aliyun nexus</name>
		<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
		<releases>
			<enabled>true</enabled>
		</releases>
		<snapshots>
			<enabled>false</enabled>
		</snapshots>
	</pluginRepository>
</pluginRepositories>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值