Создаю restfull web-framework на Kotlin
Maven в качестве сборщика, потому что Gradle не всегда стабильно работает
Packaging: JAR-архив, так как его проще запускать
JVM: 8, чтобы охватить большее количество устройств
Spring Web, Spring Data JPA, PostgreSQL Driver, Spring Actuator
<profiles>
<profile>
<id>production</id>
<properties>
<schema.name>production_schema_name</schema.name>
</properties>
</profile>
<profile>
<id>test</id>
<properties>
<schema.name>test_schema_name</schema.name>
</properties>
</profile>
</profiles>
@Table(name = "VALUES", schema = "DEV").
@Table(name = "VALUES", schema = "PROD").
@Profile
@Column (length = 2000)
private String message;
@Lob
public HttpStatus getStatus() {
RestTemplate restTemplate = new RestTemplate();
HttpEntity httpEntity = new HttpEntity(hotelbedsAuth.hotelsAuth());
ResponseEntity<String> response = restTemplate.exchange(
hotelbedsProperties.getHotelBaseUrl()+"/status", HttpMethod.GET, httpEntity, String.class);
return response.getStatusCode();
}
Once the bearer token expires, you will have to use Basic Authorization again to obtain a new bearer token.
@Scheduled
, чтобы по крону в заданный интервал времени запускать метод по обновлению токенаi think this is not possible, because this is a servlet filter, which would be applied after the spring request mapper servlet was applied. so basically, the request mapper servlet thinks it is finished, and passes the request back to the servlet container.
view names only work INSIDE of spring - outside of spring, in the servlet container, you will have to talk about urls, not view names.
@Configuration
@ConfigurationProperties(prefix = "custom")
public class AppProperties {
// названия полей должны соответствовать названиям из properties.
private String baseUrl;
private String uploadPath;
// тут геттеры
}
custom.base_url=http://localhost:8080
custom.upload_path=/home/example.com/uploads
@ConfigurationProperties(prefix = "custom")
custom.base_url
custom является префиксом..loginProcessingUrl("/login")
добавить:.usernameParameter("email")
.passwordParameter("password")
th:object
<form th:action="@{/the-action-url}" method="post"
th:object="${myEntity}">
<div class="modal-body">
<div class="form-group">
<label for="name">Name</label> <input type="text"
class="form-control" id="name" th:field="*{name}"> </input>
</div>
<div class="form-group">
<label for="description">Description</label> <input type="text"
class="form-control" id="description"
th:field="*{description}"> </input>
</div>
</div>
</form>
@PostMapping("/register")
public String register(
@ModelAttribute("username") String username,
@ModelAttribute("password") String password,
User user
) {
user.setUsername(username);
user.setPassword(password);
userRepository.save(user);
return "index";
}
@Autowired
private SomeClass someClass
@Autowired
private final SomeClass someClass;
SomeService (SomeClass someClass) {
this.someClass = someClass;
}
@Autowired
@RequiredArgsConstructor
public class PageController {
private final SomeClass1 someClass1;
private final SomeClass2 someClass2;
private final SomeClass3 someClass3;
}
.and()
.formLogin()
.loginPage("/login")
.loginProcessingUrl("/login")
.usernameParameter("email")
.passwordParameter("password")
.defaultSuccessUrl("/dashboard")
.failureUrl("/login?logout")
.permitAll()
при нажатии на вход всплывает окно и ссылка получается вида site.com/***?login
?login
- это всего лишь request parameter @PreAuthorize("hasAuthority('ADMIN')")
Пользователь должен быть админомfor (AdminProductions admrem : rmadm){
adminProductRepo.deleteById(admrem.getId());
adminProductRepo.save(admrem);
}
adminProductRepo.save(admrem);
deleteByAdminproductname()
Adminproductname