Merge branch 'master' of https://github.com/eugenp/tutorials into BAEL-16733
This commit is contained in:
commit
03977951bb
@ -1,4 +1,4 @@
|
||||
package com.baeldung.http;
|
||||
package com.baeldung.httprequest;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
@ -1,4 +1,4 @@
|
||||
package com.baeldung.http;
|
||||
package com.baeldung.httprequest;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
@ -1,8 +1,11 @@
|
||||
package com.baeldung.http;
|
||||
package com.baeldung.httprequest;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.baeldung.httprequest.FullResponseBuilder;
|
||||
import com.baeldung.httprequest.ParameterStringBuilder;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
@ -1,4 +1,4 @@
|
||||
package org.baeldung.guava;
|
||||
package org.baeldung.guava.maps.initialize;
|
||||
|
||||
import static org.hamcrest.core.IsEqual.equalTo;
|
||||
import static org.junit.Assert.*;
|
@ -1,4 +1,4 @@
|
||||
package org.baeldung.sample;
|
||||
package org.baeldung.autowire.sample;
|
||||
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
|
@ -1,10 +1,10 @@
|
||||
package org.baeldung.sample;
|
||||
package org.baeldung.autowire.sample;
|
||||
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
@ComponentScan("org.baeldung.sample")
|
||||
@ComponentScan("org.baeldung.autowire.sample")
|
||||
public class AppConfig {
|
||||
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package org.baeldung.sample;
|
||||
package org.baeldung.autowire.sample;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
@ -0,0 +1,5 @@
|
||||
package org.baeldung.autowire.sample;
|
||||
|
||||
public class FooDAO {
|
||||
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package org.baeldung.sample;
|
||||
package org.baeldung.autowire.sample;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package org.baeldung.sample;
|
||||
package org.baeldung.autowire.sample;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
@ -1,4 +1,4 @@
|
||||
package org.baeldung.sample;
|
||||
package org.baeldung.autowire.sample;
|
||||
|
||||
public interface Formatter {
|
||||
|
@ -1,4 +1,4 @@
|
||||
package org.baeldung.sample;
|
||||
package org.baeldung.autowire.sample;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
@ -1,4 +1,4 @@
|
||||
package org.baeldung.startup;
|
||||
package org.baeldung.profiles;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.env.Environment;
|
@ -1,5 +0,0 @@
|
||||
package org.baeldung.sample;
|
||||
|
||||
public class FooDAO {
|
||||
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package org.baeldung.sample;
|
||||
package org.baeldung.autowire.sample;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
@ -1,4 +1,4 @@
|
||||
package com.baeldung.annotations;
|
||||
package com.baeldung.responseentity;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.time.Year;
|
@ -1,4 +1,4 @@
|
||||
package com.baeldung.annotations;
|
||||
package com.baeldung.responseentity;
|
||||
|
||||
import java.time.Year;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.baeldung.properties;
|
||||
package com.baeldung.configurationproperties;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
@ -0,0 +1,13 @@
|
||||
package com.baeldung.configurationproperties;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableConfigurationProperties(ConfigProperties.class)
|
||||
public class DemoApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(DemoApplication.class, args);
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.baeldung.properties.conversion;
|
||||
package com.baeldung.configurationproperties;
|
||||
|
||||
public class Employee {
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.baeldung.properties.conversion;
|
||||
package com.baeldung.configurationproperties;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationPropertiesBinding;
|
||||
import org.springframework.core.convert.converter.Converter;
|
@ -1,4 +1,4 @@
|
||||
package com.baeldung.properties;
|
||||
package com.baeldung.configurationproperties;
|
||||
|
||||
public class Item {
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.baeldung.properties.conversion;
|
||||
package com.baeldung.configurationproperties;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
@ -1,4 +1,4 @@
|
||||
package com.baeldung.properties.conversion;
|
||||
package com.baeldung.configurationproperties;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.time.temporal.ChronoUnit;
|
@ -4,6 +4,8 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
|
||||
import com.baeldung.configurationproperties.ConfigProperties;
|
||||
|
||||
@SpringBootApplication
|
||||
@ComponentScan(basePackageClasses = { ConfigProperties.class, JsonProperties.class, CustomJsonProperties.class })
|
||||
public class ConfigPropertiesDemoApplication {
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.baeldung.properties;
|
||||
package com.baeldung.configurationproperties;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
@ -8,6 +8,10 @@ import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.TestPropertySource;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import com.baeldung.configurationproperties.ConfigProperties;
|
||||
import com.baeldung.properties.AdditionalProperties;
|
||||
import com.baeldung.properties.ConfigPropertiesDemoApplication;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = ConfigPropertiesDemoApplication.class)
|
||||
@TestPropertySource("classpath:configprops-test.properties")
|
@ -1,4 +1,4 @@
|
||||
package com.baeldung.properties.conversion;
|
||||
package com.baeldung.configurationproperties;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
@ -12,8 +12,8 @@ import org.springframework.test.context.TestPropertySource;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.util.unit.DataSize;
|
||||
|
||||
import com.baeldung.properties.conversion.PropertiesConversionApplication;
|
||||
import com.baeldung.properties.conversion.PropertyConversion;
|
||||
import com.baeldung.configurationproperties.PropertiesConversionApplication;
|
||||
import com.baeldung.configurationproperties.PropertyConversion;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = PropertiesConversionApplication.class)
|
@ -1,9 +1,10 @@
|
||||
package com.baeldung.freemarker.controller;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.*;
|
||||
|
||||
import com.baeldung.freemarker.method.LastCharMethod;
|
||||
import freemarker.template.DefaultObjectWrapperBuilder;
|
||||
import freemarker.template.Version;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.ui.ModelMap;
|
||||
@ -43,4 +44,12 @@ public class SpringController {
|
||||
return "redirect:/cars";
|
||||
}
|
||||
|
||||
}
|
||||
@RequestMapping(value = "/commons", method = RequestMethod.GET)
|
||||
public String showCommonsPage(Model model) {
|
||||
model.addAttribute("statuses", Arrays.asList("200 OK", "404 Not Found", "500 Internal Server Error"));
|
||||
model.addAttribute("lastChar", new LastCharMethod());
|
||||
model.addAttribute("random", new Random());
|
||||
model.addAttribute("statics", new DefaultObjectWrapperBuilder(new Version("2.3.28")).build().getStaticModels());
|
||||
return "commons";
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package com.baeldung.freemarker.method;
|
||||
|
||||
import freemarker.template.TemplateMethodModelEx;
|
||||
import freemarker.template.TemplateModelException;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class LastCharMethod implements TemplateMethodModelEx {
|
||||
public Object exec(List arguments) throws TemplateModelException {
|
||||
if (arguments.size() != 1 || StringUtils.isEmpty(arguments.get(0)))
|
||||
throw new TemplateModelException("Wrong arguments!");
|
||||
String argument = arguments.get(0).toString();
|
||||
return argument.charAt(argument.length() - 1);
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
<p>Testing is a property exists: ${student???c}</p>
|
||||
<#if status??>
|
||||
<p>Property value: ${status.reason}</p>
|
||||
<#else>
|
||||
<p>Missing property</p>
|
||||
</#if>
|
||||
|
||||
<p>Iterating a sequence:</p>
|
||||
<#list statuses>
|
||||
<ul>
|
||||
<#items as status>
|
||||
<li>${status}</li>
|
||||
</#items>
|
||||
</ul>
|
||||
<#else>
|
||||
<p>No statuses available</p>
|
||||
</#list>
|
||||
|
||||
<p>Using static methods</p>
|
||||
<#assign MathUtils=statics['java.lang.Math']>
|
||||
<p>PI value: ${MathUtils.PI}</p>
|
||||
<p>2*10 is: ${MathUtils.pow(2, 10)}</p>
|
||||
|
||||
<p>Using bean method</p>
|
||||
<p>Random value: ${random.nextInt()}</p>
|
||||
|
||||
<p>Use custom method</p>
|
||||
<p>Last char example: ${lastChar('mystring')}</p>
|
@ -1,4 +1,4 @@
|
||||
package com.baeldung.spring.controller;
|
||||
package com.baeldung.spring.requestparam;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -47,7 +47,7 @@ public class RequestParamController {
|
||||
@GetMapping("/api/foos4")
|
||||
@ResponseBody
|
||||
public String getFoos4(@RequestParam List<String> id){
|
||||
return "ID are " + id;
|
||||
return "IDs are " + id;
|
||||
}
|
||||
|
||||
@GetMapping("/foos/{id}")
|
Loading…
x
Reference in New Issue
Block a user