question
The problems encountered this week are mainly environmental issues
The first is the problem left over from history. The MySQL version problem was not solved in time. At that time, I thought about when I encountered a problem, and then there was no problem when running the log system. Later, there was a problem in the wisdom community. In fact, MySQL was not installed at that time. At that time, xampp was installed, and then the built-in MySQL service of xampp was used. There was no way but to reinstall MySQL.
After installing mysql, I encountered a very outrageous problem, and the terminal input was abnormal
After solving this, I found that there was a problem with the database
Change the username and password again, and log in again.
The second is that navicat suddenly can’t be used. It can be used normally before the new year, and then the computer has never been turned on. After the new year, I found that it suddenly couldn’t be turned on. After trying various methods, I chose another one. Software, DBeaver
At present, it feels good to use. The point is that it is free. You don't need to bother to crack or find a cracked version like navicat.
DBeaver installation using
nginx
I have been in touch with nginx when I learned thinkphp before, but I only used http server, so I don't know how to use nginx at all.
what is nginx
Nginx (engine x) is a lightweight web server, reverse proxy server and email (IMAP/POP3) proxy server.
What is a reverse proxy?
Reverse Proxy means that the proxy server accepts the connection request on the internet, then forwards the request to the server on the internal network, and returns the result obtained from the server to the client requesting the connection on the internet. At this point, the proxy server acts as a reverse proxy server to the outside world.
I understand the process
And the process without nginx is
After I sorted out this process for the first time, I felt that nginx was a bit tasteless
Why can't you directly access the foreground and directly access the background from the foreground?
Why use nginx
1. The real web server is protected, the web server is invisible to the outside world, and the external network can only see the reverse proxy server, and there is no real data on the reverse proxy server, so the resource security of the web server is guaranteed.
2. Based on reverse proxy, dynamic and static resource separation and load balancing methods are generated, which reduces the burden on web servers and speeds up access to websites.
3. It saves limited IP address resources. All websites in the enterprise share an IP address registered in the internet. These servers allocate private addresses and use virtual hosts to provide services to the outside world.
Separation of dynamic and static resources: The separation of dynamic and static resources is to allow the dynamic web pages in a dynamic website to distinguish constant resources from frequently changing resources according to certain rules. After the dynamic and static resources are separated, we can separate them according to the characteristics of static resources Doing cache operation, this is the core idea of website static processing
Load Balancing: Distributing work across multiple servers
Common commands
nginx 启动
nginx -s stop 快速关闭Nginx,可能不保存相关信息,并迅速终止web服务。
nginx -s quit 平稳关闭Nginx,保存相关信息,有安排的结束web服务。
nginx -s reload 因改变了Nginx相关配置,需要重新加载配置而重载。
nginx -s reopen 重新打开日志文件。
nginx -c filename 为 Nginx 指定一个配置文件,来代替缺省的。
nginx -t 不运行,而仅仅测试配置文件。nginx 将检查配置文件的语法的正确性,并尝试打开配置文件中所引用到的文件。
nginx -v 显示 nginx 的版本。
nginx -V 显示 nginx 的版本,编译器版本和配置参数。
When using it, you only need to include the nginx.conf file of the project in nginx.conf.
For more information on nginx configuration files, please refer to
Nginx Simple Tutorial
Detailed nginx configuration file
@JsonView
Introduction
@JsonView is an annotation of Jackson that can be used to filter the field properties of the serialized object. You can choose which properties of the serialized object to filter out.
It can be simply understood as a filter, which can process the entity as needed and return the required data instead of the entire entity
specific use
First create the interface in the entity
// 视图1
public interface OneView{};
// 视图2 继承视图1
public interface TwoView extends OneView{};
Then add the annotation to the get method
@JsonView(OneView.class)
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
@JsonView(OneView.class)
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
@JsonView(TwoView.class)
public String getRealName() {
return realName;
}
public void setRealName(String realName) {
this.realName = realName;
}
@JsonView(TwoView.class)
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
}
Finally, add an annotation to the controller method
@RestController
@RequestMapping("/user")
public class UserController {
@GetMapping("/user1")
@JsonView(OneView.class)
public User queryUser1() {
User user = new User();
user.setUsername("test1");
user.setPassword("123456");
user.setRealName("测试");
user.setSex("男");
return user;
}
@GetMapping("/user2")
@JsonView(TwoView.class)
public User queryUser2( String id) {
User user = new User();
user.setUsername("test1");
user.setPassword("123456");
user.setRealName("测试");
user.setSex("男");
return user;
}
This way you can get different results when accessing the two methods
When accessing user1 is
user2 is
But this usage is different from the project
In the project, the annotation is directly added to the member of the entity instead of the get method
@ApiModelProperty("负责小区")
@OneToMany(mappedBy = "propertyCompany")
@JsonView(VillageJsonView.class)
@Where(clause = "deleted = false")
private List<Village> villages = new ArrayList<>();
After testing, adding annotations to members or get methods has the same effect
What I started to understand is that all annotations will be displayed, and those without annotations or other annotations will be filtered out.
After testing it myself, I found that only those adding other annotations will be filtered out, and those without annotations will not be filtered.
Summarize
Spend too much time on environmental issues, and now I start writing the background and find that there is still a lot to learn
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。