@GetMapping(value = "/result")
public int addition(
@ApiParam(value = "FirstValue", required = true, type = "string", defaultValue = "0") @RequestParam(value = "firstValue", required = true) Integer x,
@ApiParam(value = "SecondValue", required = true, type = "string", defaultValue = "0") @RequestParam(value = "secondValue", required = true) Integer y) {
return x + y;
}
在刷新大方的用户界面页面时,我们遇到以下错误
2019-06-26 15:44:11.484 WARN 16667 --- [nio-7854-exec-3] i.s.m.p.AbstractSerializableParameter : Illegal DefaultValue 0 for parameter type integer
java.lang.NumberFormatException: For input string: ""
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65) ~[na:1.8.0_144]
at java.lang.Long.parseLong(Long.java:601) ~[na:1.8.0_144]
at java.lang.Long.valueOf(Long.java:803) ~[na:1.8.0_144]
at io.swagger.models.parameters.AbstractSerializableParameter.getExample(AbstractSerializableParameter.java:412) ~[swagger-models-1.5.20.jar:1.5.20]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_144]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_144]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_144]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_144]
答案 0 :(得分:2)
删除旧版本(1.5.20)并添加新版本。
annual_salary = float(input('Enter your annual salary:')) #120000
portion_saved = float(input('Enter the percent of your salary to save, as a decimal:')) #.05
total_cost = float(input('Enter the cost of your dream home:')) #500000
semi_annual_raise = float(input('Enter the semiannual raise, as a decimal: ')) #.03
portion_down_payment = .25 * total_cost
current_savings = 0
annual_return_rate = .04
portion_saved_monthly = annual_salary / 12 * portion_saved
current_savings = current_savings + portion_saved_monthly
month = 1
while current_savings < portion_down_payment:
current_savings += (current_savings * annual_return_rate / 12) + portion_saved_monthly
month += 1
if month % 6 == 0:
annual_salary += annual_salary * semi_annual_raise
portion_saved_monthly = annual_salary / 12 * portion_saved
current_savings += (current_savings * annual_return_rate / 12) + portion_saved_monthly
print('Number of months: ', month)
或忽略
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.9.2</version>
<exclusions>
<exclusion>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
</exclusion>
<exclusion>
<groupId>io.swagger</groupId>
<artifactId>swagger-models</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
<version>1.5.21</version>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-models</artifactId>
<version>1.5.21</version>
</dependency>
答案 1 :(得分:0)
这不是错误,只是严重性警告的日志,可通过使用
来忽略logging.level.io.swagger.models.parameters.AbstractSerializableParameter=error
关于application.properties。根据我的经验,他不会为整数设置值0(我认为这是因为int类型的默认值)。
关于将类型显示为ref,这是因为integer并非接受的值之一。对于java.lang.Integer或原始int,应在swagger中使用类型“ int”。我接受的其他值包括:“ long”(对于java.lang.Long和long),“ bigInteger”(对于java.math.BigInteger),当然还有“ string”(对于java.lang.String)。 / p>