Spring Boot代码结构

from flask import Flask
app = Flask(__name__)
@app.route('/user/tom')
def show_user_tom():
return 'My name is tom'
@app.route('/user/jerry')
def show_user_jerry():
return 'My name is jerry'
@app.route('/user/mike')
def show_user_mike():
return 'My name is mike'
if __name__ == '__main__':
app.run()
from flask import Flaskapp = Flask(__name__)
@app.route('/user/<name>')
def show_user(name):
return 'My name is %s' % name
if __name__ == '__main__':
app.run()
from flask import Flaskapp = Flask(__name__)
@app.route('/user/<name>')
def show_user(name):
return 'My name is %s' % name
@app.route('/age/<int:age>')
def show_age(age):
return 'age is %d' % age
@app.route('/price/<float:price>')
def show_price(price):
return 'price is %f' % price
@app.route('/path/<path:name>')
def show_path(name):
return 'path is %s' % name
if __name__ == '__main__':
app.run()
@app.route('/all/<path:path>/name/<string:name>/age/<int:age>/price/<float:price>')
def show_all(name, path, age, price):
return f"path is {path}\nname is {name}\nage is {age}\nprice is {price}"
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
  <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
@ConfigurationProperties(prefix = "weak.password")
public class CheckWeakPasswordProperties {

private Boolean enabled = true;
/**
* 需要检查的URI数组
*/
private String[] checkUri;
/**
* 拦截检查的方式 1-interceptor 2-filter 3-aop
*/
private Integer checkType = 1;
private String ip = "127.0.0.1";
private String port = "8501";
/**
* 客户端名称
*/
private String clientName = "cloud-user";
/**
* 校验失败信息提示
*/
private String failureMessage = "密码等级不够";       ...// 省略getter/setter方法
@Configuration
@EnableConfigurationProperties(CheckWeakPasswordProperties.class)
@ConditionalOnProperty(prefix = "weak.password", name = "enabled", havingValue = "true")
public class CheckWeakPasswordAutoConfiguration {

public CheckWeakPasswordAutoConfiguration() {
}

@Bean
@ConditionalOnProperty(prefix = "weak.password", name = "checkType", havingValue = "2")
public CheckPasswordInterceptor checkPasswordInterceptor(){
return new CheckPasswordInterceptor();
}
@Bean
@ConditionalOnProperty(prefix = "weak.password", name = "checkType", havingValue = "2")
public CheckPasswordFilter checkPasswordFilter(){
return new CheckPasswordFilter();
}
@Bean
@ConditionalOnProperty(name = "weak.password.check-type", havingValue = "2")
public CheckPasswordFilterConfig checkPasswordFilterConfig() {
return new CheckPasswordFilterConfig();
}
@Bean
@ConditionalOnProperty(prefix = "weak.password", name = "checkType", havingValue = "1")
public CheckPasswordInterceptorConfig checkPasswordInterceptorConfig(){
return new CheckPasswordInterceptorConfig();
}"groups": [
{
"name": "weak.password",
"type": "com.yunchuang.password.properties.CheckWeakPasswordProperties",
"sourceType": "com.yunchuang.password.properties.CheckWeakPasswordProperties"
}
],
"properties": [
{
"name": "weak.password.check-type",
"type": "java.lang.Integer",
"description": "拦截检查的方式 1-interceptor 2-filter 3-aop",
"sourceType": "com.yunchuang.password.properties.CheckWeakPasswordProperties",
"defaultValue": 1
},
{
"name": "weak.password.check-uri",
"type": "java.lang.String[]",
"description": "需要检查的URI数组",
"sourceType": "com.yunchuang.password.properties.CheckWeakPasswordProperties"
},
{
"name": "weak.password.client-name",
"type": "java.lang.String",
"description": "客户端名称",
"sourceType": "com.yunchuang.password.properties.CheckWeakPasswordProperties",
"defaultValue": "cloud-user"
},
{
"name": "weak.password.enabled",
"type": "java.lang.Boolean",
"sourceType": "com.yunchuang.password.properties.CheckWeakPasswordProperties",
"defaultValue": true
},
{
"name": "weak.password.failure-message",
"type": "java.lang.String",
"description": "校验失败信息提示",
"sourceType": "com.yunchuang.password.properties.CheckWeakPasswordProperties",
"defaultValue": "密码等级不够"
},
{
"name": "weak.password.ip",
"type": "java.lang.String",
"sourceType": "com.yunchuang.password.properties.CheckWeakPasswordProperties",
"defaultValue": "127.0.0.1"
},
{
"name": "weak.password.port",
"type": "java.lang.String",
"sourceType": "com.yunchuang.password.properties.CheckWeakPasswordProperties",
"defaultValue": "8501"
}
],
"hints": []
}

posted @ 2021-09-02 09:16  v17166570219  阅读(135)  评论(0)    收藏  举报