跳至主要內容

maven 配置

OrangBus大约 3 分钟

后端技术

技术说明官网
SpringBoot容器+MVC框架https://spring.io/projects/spring-boot
SpringSecurity认证和授权框架https://spring.io/projects/spring-security
MyBatisORM框架http://www.mybatis.org/mybatis-3/zh/index.html
MyBatisGenerator数据层代码生成http://www.mybatis.org/generator/index.html
Elasticsearch搜索引擎https://github.com/elastic/elasticsearch
RabbitMQ消息队列https://www.rabbitmq.com/
Redis分布式缓存https://redis.io/
MongoDBNoSql数据库https://www.mongodb.comopen in new window
LogStash日志收集工具https://github.com/elastic/logstash
Kibina日志可视化查看工具https://github.com/elastic/kibana
Nginx静态资源服务器https://www.nginx.com/
Docker应用容器引擎https://www.docker.comopen in new window
Jenkins自动化部署工具https://github.com/jenkinsci/jenkins
Druid数据库连接池https://github.com/alibaba/druid
OSS对象存储https://github.com/aliyun/aliyun-oss-java-sdk
MinIO对象存储https://github.com/minio/minio
JWTJWT登录支持https://github.com/jwtk/jjwt
Lombok简化对象封装工具https://github.com/rzwitserloot/lombok
HutoolJava工具类库https://github.com/looly/hutool
PageHelperMyBatis物理分页插件http://git.oschina.net/free/Mybatis_PageHelper
Swagger-UI文档生成工具https://github.com/swagger-api/swagger-ui
Hibernator-Validator验证框架http://hibernate.org/validator

前端技术

技术说明官网
Vue前端框架https://vuejs.org/
Vue-router路由框架https://router.vuejs.org/
Vuex全局状态管理框架https://vuex.vuejs.org/
Element前端UI框架https://element.eleme.ioopen in new window
Axios前端HTTP框架https://github.com/axios/axios
v-charts基于Echarts的图表框架https://v-charts.js.org/
Js-cookiecookie管理工具https://github.com/js-cookie/js-cookie
nprogress进度条控件https://github.com/rstacruz/nprogress
<?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">
    <parent>
        <artifactId>spring</artifactId>
        <groupId>org.example</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>jdbc</artifactId>

    <properties>
        <maven.compiler.source>8</maven.compiler.source>
        <maven.compiler.target>8</maven.compiler.target>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <version>5.3.9</version>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>8.0.25</version>
        </dependency>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.13.2</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
            <version>5.2.16.RELEASE</version>
        </dependency>
    </dependencies>

</project>

mysql

<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>8.0.25</version>
</dependency>

mysql连接

 <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName" value="com.mysql.cj.jdbc.Driver" />
        <property name="url" value="jdbc:mysql://localhost/spring_jdbc?useUnicode=true&amp;characterEncode=UTF-8" />
        <property name="username" value="root" />
        <property name="password" value="root" />
    </bean>

mybatis

单元测试

<dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>4.13.2</version>
    <scope>test</scope>
</dependency>

spring

<!-- https://mvnrepository.com/artifact/org.springframework/spring-context -->
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-context</artifactId>
    <version>5.2.9.RELEASE</version>
</dependency>

spring-test 单元测试

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-test</artifactId>
    <version>5.2.16.RELEASE</version>
</dependency>

spring-jdbc 数据库交互

<dependency>
     <groupId>org.springframework</groupId>
     <artifactId>spring-jdbc</artifactId>
     <version>5.3.9</version>
</dependency>

json序列化

spring-boot

xml-header

aplicationContent.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
</beans>

资源过滤

 <build>
     <resources>
         <resource>
             <directory>src/main/resources</directory>
             <includes>
                 <include>**/*.properties</include>
                 <include>**/*.xml</include>
             </includes>
             <filtering>true</filtering>
         </resource>
         <resource>
             <directory>src/main/java</directory>
             <includes>
                 <include>**/*.properties</include>
                 <include>**/*.xml</include>
             </includes>
             <filtering>true</filtering>
         </resource>
     </resources>
</build>

资源加载

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
  PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
  "http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
  <environments default="development">
    <environment id="development">
      <transactionManager type="JDBC"/>
      <dataSource type="POOLED">
        <property name="driver" value="${driver}"/>
        <property name="url" value="${url}"/>
        <property name="username" value="${username}"/>
        <property name="password" value="${password}"/>
      </dataSource>
    </environment>
  </environments>
    
  <mappers>
    <mapper resource="org/mybatis/example/BlogMapper.xml"/>
  </mappers>
    
</configuration>

db.properties配置文件

外部引入大于当前配置这里相当于是默认配置 注意点 url的地址正常写就可以了,不用 & 转换 resource="db.properties"

driver=com.mysql.cj.jdbc.Driver
url=jdbc:mysql://localhost/mybatis?useUnicode=true&characterEncode=UTF-8
#url=jdbc:mysql://localhost/mybatis?useUnicode=true&amp;characterEncode=UTF-8  报错
username=root
password=root

mybatis.xml

 <properties resource="db.properties">
        <property name="driver" value="com.mysql.cj.jdbc.Driver"/>
        <property name="url" value="jdbc:mysql://localhost/mybatis?useUnicode=true&amp;characterEncode=UTF-8"/>
        <property name="username" value="root"/>
        <property name="password" value="root"/>
    </properties>

别名

mybatis.xml

<typeAliases>
	<typeAlias type="com.orangbus.model.User" alias="User"></typeAlias>
</typeAliases>

<typeAliases>
	<typeAlias type="com.orangbus.model"></typeAlias>
</typeAliases>

也可以在实体类名前面 注解

@Alias("user")