编程知识 cdmana.com

[learning notes] error recording and summary reflection in Java Web project completed in two months

Preface

Make some technical mistakes here , For personal summary only ( No project details )

Start a little memory and update ……

 

front end

1. layui Paging failure problem

 

 

Back end

1. yml Array definition and call

application.yml File example

ips:
  - one
  - two
count:
  12

java In the process yml Array call

try {
    Yaml yaml = new Yaml();//  This needs to be done jar Package for :org.yaml.snakeyaml
    //MailConfig  This is the class name of the class where the main function is located 
    InputStream resourceAsStream = MailConfig.class.getClassLoader().getResourceAsStream("application.yml");
    // Load stream , obtain yaml Configuration data in the file , And then convert to Map,
    Map obj = (Map) yaml.load(resourceAsStream);
    System.out.println(obj);
    //  obtain ips Array 
    List ips = (List) obj.get("ips");
    System.out.println(ips);    //  obtain [one, two]
    int count = (int) obj.get("count");
    System.out.println(count);    //  obtain 12
} catch (Exception e) {
    e.printStackTrace();
    System.out.println(e.getMessage());
}

 

database

 

 

Deploy

1. In the project src The same level directory resource Store the relevant configuration files in , Read property It works with the following syntax

FileInputStream ips=new FileInputStream("resource/db.properties");

When the project is deployed to tomcat after , Configuration file read failed .

Because of the fight war You'll find after the bag , No, resource This directory , The configuration file directly and src The project package under is in a directory

try {
    FileInputStream in=new FileInputStream(HiveDao.class.getResource("/").getPath() + "/db.properties");
    Properties properties=new Properties();
    properties.load(in);
}catch(FileNotFoundException e){
    e.printStackTrace();
}catch(IOException e){
    e.printStackTrace();
}

 

 

other

 

summary

I got into contact with the first complete project , from 0 Start talking about needs 、 The whole process 、 Design the system 、 Development 、 test , Although the system is not very difficult, it's not very difficult , But the whole process is very helpful for me to establish the thinking of programming and project development !

版权声明
本文为[osc_ j9nll12v]所创,转载请带上原文链接,感谢
https://cdmana.com/2020/12/20201224090421667k.html

Scroll to Top