添加更多注解

master
barney 2 years ago
parent 9b00663116
commit dd65ce6963
  1. 8
      SpringAOP/src/test/java/cc/bnblogs/springaop/service/UserServiceTest.java
  2. 7
      annotations/pom.xml
  3. 17
      annotations/src/main/java/cc/bnblogs/annotations/controller/PersonController.java
  4. 48
      annotations/src/main/java/cc/bnblogs/annotations/entity/Person.java
  5. 10
      annotations/src/main/resources/application.properties
  6. 4
      annotations/src/main/resources/static/person.properties

@ -3,12 +3,18 @@ package cc.bnblogs.springaop.service;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import static org.junit.jupiter.api.Assertions.*;
@SpringBootTest
class UserServiceTest {
@Autowired
private UserService userService;
@Autowired
public UserServiceTest(UserService userService) {
this.userService = userService;
}
@Test
void funA() {

@ -21,11 +21,18 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-freemarker</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>

@ -0,0 +1,17 @@
package cc.bnblogs.annotations.controller;
import cc.bnblogs.annotations.entity.Person;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class PersonController {
@Autowired
private Person person;
@GetMapping("/person/")
public Person getPerson() {
return person;
}
}

@ -0,0 +1,48 @@
package cc.bnblogs.annotations.entity;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;
@Component
@PropertySource(value = {"classpath:static/person.properties"})
@ConfigurationProperties(prefix = "person")
public class Person {
private String name;
private String password;
private String sex;
private Integer age;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
}
public Integer getAge() {
return age;
}
public void setAge(Integer age) {
this.age = age;
}
}

@ -6,7 +6,15 @@ spring.mvc.view.suffix=.html
spring.freemarker.suffix=.html
spring.freemarker.template-loader-path=classpath:/static/
# ???????
# \u7F16\u7801\u8BBE\u7F6E\u4E3AUTF-8
server.servlet.encoding.force=true
server.servlet.encoding.charset=UTF-8
my.page=1
local.username=admin
local.password=admin123
#person.name=admin
#person.password=123123
#person.sex=\u7537
#person.age=18

@ -0,0 +1,4 @@
person.name=admin
person.password=123123
person.sex=\u5973
person.age=18
Loading…
Cancel
Save