init project
This commit is contained in:
8
acs/hd/nladmin-test/src/main/java/org/nl/Cat.java
Normal file
8
acs/hd/nladmin-test/src/main/java/org/nl/Cat.java
Normal file
@@ -0,0 +1,8 @@
|
||||
package org.nl;
|
||||
|
||||
public class Cat implements IShout {
|
||||
@Override
|
||||
public void shout() {
|
||||
System.out.println("miao miao111");
|
||||
}
|
||||
}
|
||||
8
acs/hd/nladmin-test/src/main/java/org/nl/Dog.java
Normal file
8
acs/hd/nladmin-test/src/main/java/org/nl/Dog.java
Normal file
@@ -0,0 +1,8 @@
|
||||
package org.nl;
|
||||
|
||||
public class Dog implements IShout {
|
||||
@Override
|
||||
public void shout() {
|
||||
System.out.println("wang wang");
|
||||
}
|
||||
}
|
||||
5
acs/hd/nladmin-test/src/main/java/org/nl/IShout.java
Normal file
5
acs/hd/nladmin-test/src/main/java/org/nl/IShout.java
Normal file
@@ -0,0 +1,5 @@
|
||||
package org.nl;
|
||||
|
||||
public interface IShout {
|
||||
void shout();
|
||||
}
|
||||
27
acs/hd/nladmin-test/src/main/java/org/nl/Test111.java
Normal file
27
acs/hd/nladmin-test/src/main/java/org/nl/Test111.java
Normal file
@@ -0,0 +1,27 @@
|
||||
package org.nl;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.ServiceLoader;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@Api(tags = "运维:应用管理")
|
||||
@RequestMapping("/api/test")
|
||||
public class Test111 {
|
||||
public static void main(String[] args) {
|
||||
ServiceLoader<IShout> shouts = ServiceLoader.load(IShout.class);
|
||||
for (IShout s : shouts) {
|
||||
s.shout();
|
||||
}
|
||||
}
|
||||
@GetMapping(value = "/test")
|
||||
public String getStr() {
|
||||
return "hello";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package org.nl.starter;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
@ConfigurationProperties(prefix = "spring.tian")
|
||||
@Data
|
||||
public class TianProperties {
|
||||
private String name;
|
||||
private int age;
|
||||
private String sex = "M";
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package org.nl.starter;
|
||||
|
||||
public class TianService {
|
||||
private TianProperties properties;
|
||||
public TianService() {
|
||||
}
|
||||
public TianService(TianProperties userProperties) {
|
||||
this.properties = userProperties;
|
||||
}
|
||||
public void sayHello(){
|
||||
System.out.println("hi, 我叫: " + properties.getName() +
|
||||
", 今年" + properties.getAge() + "岁"
|
||||
+ ", 性别: " + properties.getSex());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package org.nl.starter;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
@EnableConfigurationProperties(TianProperties.class)
|
||||
@ConditionalOnClass(TianService.class)
|
||||
@ConditionalOnProperty(prefix = "spring.tian", value = "enabled", matchIfMissing = true)
|
||||
public class TianServiceAutoConfiguration {
|
||||
@Autowired
|
||||
private TianProperties properties;
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(TianService.class)
|
||||
public TianService tianService() {
|
||||
return new TianService(properties);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
org.nl.Cat
|
||||
org.nl.Dog
|
||||
@@ -0,0 +1,2 @@
|
||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=org.nl.starter.TianServiceAutoConfiguration
|
||||
|
||||
19
acs/hd/nladmin-test/src/test/java/Test.java
Normal file
19
acs/hd/nladmin-test/src/test/java/Test.java
Normal file
@@ -0,0 +1,19 @@
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class Test {
|
||||
public static void main(String[] args) {
|
||||
JSONObject json=new JSONObject();
|
||||
json.put("id","1493102834739187714");
|
||||
System.out.println(json.getLong("id"));
|
||||
System.out.println(json.getString("id"));
|
||||
|
||||
HashMap map=new HashMap();
|
||||
map.put("a","1");
|
||||
map.put("b","2");
|
||||
JSONObject jsonObject = JSONObject.parseObject(JSON.toJSONString(map));
|
||||
System.out.println(jsonObject);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user