Zzx Blog

Since 2017


  • 首页

  • 标签

  • 分类

  • 归档

  • 公益404

  • 搜索

SpringBoot项目部署问题

发表于 2018-04-08 | 分类于 Java , SpringBoot

SpringBoot项目部署到linux系统相关问题

  • linux tomcat日志错误Cannot run without an instance id & java.net.UnknownHostException
  • 解决方案:vi 编辑 /etc/hosts文件,将当前服务器主机名加入127.0.0.1这一行即可
  • 获取服务器服务器主机名方法:命令行输入hostname
    阅读全文 »

关于JavaBean-POJO

发表于 2018-03-20 | 分类于 Java

POJO实体类属性-private

  • 为了安全
  • 为什么安全?别的类可以通过直接调用对象.属性名调用或者任意赋值。
  • 用get,set可以控制某些属性只读或只写
  • POJO本身就是对外开放的接口,通过方法调用

Spring依赖注入方式

发表于 2018-03-06 | 分类于 Java , Spring

Spring依赖注入方式

  1. @Autowired与@Resource都可以用来装配bean. 都可以写在字段上,或写在setter方法上。
  2. @Autowired默认按类型装配(这个注解是属业spring的),默认情况下必须要求依赖对象必须存在,如果要允许null值,可以设置它的required属性为false,如:@Autowired(required=false) ,如果我们想使用名称装配可以结合@Qualifier注解进行使用,如下:

    1
    2
    @Autowired() @Qualifier("baseDao")    
    private BaseDao baseDao;
  3. @Resource 是JDK1.6支持的注解,默认按照名称进行装配,名称可以通过name属性进行指定,如果没有指定name属性,当注解写在字段上时,默认取字段名,按照名称查找,如果注解写在setter方法上默认取属性名进行装配。当找不到与名称匹配的bean时才按照类型进行装配。但是需要注意的是,如果name属性一旦指定,就只会按照名称进行装配。只不过注解处理器我们使用的是Spring提供的,是一样的,无所谓解耦不解耦的说法,两个在便利程度上是等同的。

    1
    2
    @Resource(name="baseDao")    
    private BaseDao baseDao;
  • 他们的主要区别就是@Autowired是默认按照类型装配的 @Resource默认是按照名称装配的byName 通过参数名 自动装配,如果一个bean的name 和另外一个bean的 property 相同,就自动装配。byType 通过参数的数据类型自动自动装配,如果一个bean的数据类型和另外一个bean的property属性的数据类型兼容,就自动装配
    阅读全文 »

SpringBoot注解

发表于 2018-03-05 | 分类于 Java , SpringBoot

##SpringBoot注解使用

  1. @SpringBootApplication
  • @SpringBootApplication = (默认属性)@Configuration + @EnableAutoConfiguration + @ComponentScan。
    1
    2
    3
    4
    5
    6
    @SpringBootApplication  
    public class ApplicationMain {
    public static void main(String[] args) {
    SpringApplication.run(Application.class, args);
    }
    }
  • @Configuration:提到@Configuration就要提到他的搭档@Bean。使用这两个注解就可以创建一个简单的spring配置类,可以用来替代相应的xml配置文件。
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    Spring配置文件
    <beans>
    <bean id = "car" class="com.test.Car">
    <property name="wheel" ref = "wheel"></property>
    </bean>
    <bean id = "wheel" class="com.test.Wheel"></bean>
    </beans>
    相当于
    @Configuration
    public class Conf {
    @Bean
    public Car car() {
    Car car = new Car();
    car.setWheel(wheel());
    return car;
    }
    @Bean
    public Wheel wheel() {
    return new Wheel();
    }
    }
阅读全文 »

Spring注解

发表于 2018-03-05 | 分类于 Java , Spring

Spring注解

  1. @Autowired
  • @Autowired 注释,它可以对类成员变量、方法及构造函数进行标注,完成自动装配的工作。 通过 @Autowired的使用来消除 set ,get方法。在使用@Autowired之前,我们对一个bean配置起属性时,是这用用的

    1
    <property name="属性名" value=" 属性值"/>
  • 具体例子:

  • UserRepository.java

    1
    2
    3
    4
    5
    6
    1 package com.proc.bean.repository;
    2
    3 public interface UserRepository {
    4
    5 void save();
    6 }
  • 这里定义了一个UserRepository接口,其中定义了一个save方法

  • UserRepositoryImps.java
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    package com.proc.bean.repository;

    import org.springframework.stereotype.Repository;

    @Repository("userRepository")
    public class UserRepositoryImps implements UserRepository{

    @Override
    public void save() {
    System.out.println("UserRepositoryImps save");
    }
    }
阅读全文 »

SpringBoot入门

发表于 2018-03-05 | 分类于 Java , SpringBoot

SpringBoot依赖

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<!-- springboot组件-->
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.9.RELEASE</version>
</parent>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<servlet.version>3.1.0</servlet.version>
<junit.version>4.12</junit.version>
<jedis.version>2.9.0</jedis.version>
<druid.version>1.1.6</druid.version>
<mybatisplus.version>2.1.6</mybatisplus.version>
<mybatisplus.spring.boot.version>1.0.5</mybatisplus.spring.boot.version>
<mysql.version>5.1.38</mysql.version>
<commons.lang.version>2.6</commons.lang.version>
<commons.fileupload.version>1.3.1</commons.fileupload.version>
<commons.io.version>2.5</commons.io.version>
<commons.codec.version>1.10</commons.codec.version>
<fastjson.version>1.2.45</fastjson.version>
</properties>
阅读全文 »

SpringMVC整合Mybatis

发表于 2017-12-04 | 分类于 Java , SpringMVC , MyBatis

Maven依赖(mybatis,mysql,oracle,druid连接池)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<!-- mybatis/spring包 -->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.4.1</version>
</dependency>

<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>1.3.0</version>
</dependency>

<!--mysql驱动包-->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.35</version>
</dependency>

<!-- Druid -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.0.26</version>
</dependency>


<!-- oracle driver -->
<dependency>
<groupId>com.oracle.driver</groupId>
<artifactId>jdbc</artifactId>
<version>14</version>
<scope>runtime</scope>
</dependency>
阅读全文 »

SpringMVC配置及整合spring security

发表于 2017-11-30 | 分类于 Java , SpringMVC

SpringMVC

  1. pom文件
  2. springmvc配置
  3. web.xml
  4. spring security配置
  5. java代码

    阅读全文 »

BootStrap-Table

发表于 2017-11-23 | 分类于 Javascript , BootStrap

Bootstrap中文网
Bootstrap-table中文api
Bootstrap-table官网

引入css

bootstrap/css/bootstrap.min.css
bootstrap-table/src/bootstrap-table.css

  • 行内编辑
    文档地址
    bootstrap3-editable/css/bootstrap-editable.css

引入js

bootstrap/js/bootstrap.min.js
bootstrap-table/src/bootstrap-table.js
bootstrap-table/src/extensions/filter-control/bootstrap-table-filter-control.js
bootstrap-table/src/extensions/toolbar/bootstrap-table-toolbar.js
https://cdn.bootcss.com/x-editable/1.5.1/bootstrap3-editable/js/bootstrap-editable.min.js
bootstrap-table/src/extensions/editable/bootstrap-table-editable.js

  • 中文包
    bootstrap-table/locale/bootstrap-table-zh-CN.min.js

Html代码

  • 可在html配置,或者js配置(本文html配置)

    阅读全文 »

ztree使用(右键点击操作菜单)

发表于 2017-11-23 | 分类于 Javascript

Ztree的使用

  • 效果展示
    文件夹操作
    文件操作
  • html
    1
    <ul id="fileTree" class="ztre" style="background-color:#fff;border:none;margin-top:0;width:100%;height:180px;"></ul>

引入css文件ztree/css/metroStyle/metroStyle.css ztree/js/jquery.ztree.core-3.5.js

  • js
  1. 配置setting,ztreeapi
    阅读全文 »
1…567
Banksy Zhuang

Banksy Zhuang

66 日志
36 分类
40 标签
Github E-Mail
© 2017 — 2024 Banksy Zhuang
本站已运行