Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test #1

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
public class hellocontroller {
@RequestMapping("/hello")
public String hello(){
return "hello";
return "hello22";
// lllll
}

}
37 changes: 37 additions & 0 deletions src/main/java/com/cqu/springdemo/pojo/Dog.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.cqu.springdemo.pojo;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

@Component
@ConfigurationProperties(prefix = "dog")
public class Dog {
@Override
public String toString() {
return "Dog{" +
"name='" + name + '\'' +
", age=" + age +
'}';
}

private String name;
private int age;

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public int getAge() {
return age;
}

public void setAge(int age) {
this.age = age;
}


}
45 changes: 45 additions & 0 deletions src/main/java/com/cqu/springdemo/pojo/Person.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package com.cqu.springdemo.pojo;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

@Component
@ConfigurationProperties(prefix = "person")
public class Person {
public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public int getAge() {
return age;
}

public void setAge(int age) {
this.age = age;
}

public Dog getDog() {
return dog;
}

public void setDog(Dog dog) {
this.dog = dog;
}

@Override
public String toString() {
return "Person{" +
"name='" + name + '\'' +
", age=" + age +
", dog=" + dog +
'}';
}

private String name;
private int age;
private Dog dog;
}
1 change: 0 additions & 1 deletion src/main/resources/application.properties

This file was deleted.

14 changes: 14 additions & 0 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
server:
port: 8081
dog:
name: "旺财"
age: 10

person:
name: "jack"
age: 10

dog:
name: ${person.goof:hello}_456
age: 10

Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
package com.cqu.springdemo;

import com.cqu.springdemo.pojo.Dog;
import com.cqu.springdemo.pojo.Person;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

@SpringBootTest
class SpringdemoApplicationTests {

@Autowired
private Dog dog;
@Autowired
private Person person;
@Test
void contextLoads() {
System.out.println(person);
}

}