List<GrowBox> findByUserId(Long userId);List<GrowBox> findAllByUserUserId(Long userId) если мне память не изменяет, то должно быть как-то такList<GrowBox> findAllByUser(User user);No property userId found for type GrowBox!
Caused by: org.springframework.data.mapping.PropertyReferenceException: No property userId found for type GrowBox!
Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.
<form th:action="@{/register}"
th:object="${personForm}" method="POST">
Login:
<input type="text" th:field="*{name}" />
<br/>
Email:
<input type="text" th:field="*{email}" />
<br/>
Password:
<input type="text" th:field="*{password}">
<br/>
Confirm password:
<input type="text" th:field="*{doublePassword}">
<input type="submit" value="Create" />
</form><form th:action="@{/register}"
th:object="${personForm}" method="POST">
Login:
<input type="text" th:field="*{name}" />
<br/>
Email:
<input type="email" th:field="*{email}" />
<br/>
Password:
<input type="password" th:field="*{password}">
<br/>
Confirm password:
<input type="password">
<input type="submit" value="Create" />
</form>model.addAttribute() и вывести в шаблоне@RequestMapping(value = {"/register"} , method = RequestMethod.POST)
public String savePerson(Model model, @ModelAttribute("personForm") UserForm personForm) {
if(!personForm.getPassword.equals(personForm.getPasswordConfirmation)) {
model.addAttribute("passwordIncorrect", "Вы ввели некорректный пароль");
return "register";
}
if(personForm.checkPassword() &&
userRepository.findByEmail(personForm.getEmail()) == null &&
userRepository.findByName(personForm.getName()) == null) {
AppUser user = new AppUser(personForm.getName(),
personForm.getEmail(),
personForm.getPassword());
user.setEnabled(true);
user.setRoles(Collections.singleton(Role.USER));
userRepository.save(user);
return "home";
}
return "register";
}logging.level.org.springframework.security=DEBUG
logging.level.org.hibernate.SQL=DEBUG
logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE
logging.level.org.hibernate.type=TRACE2019-05-25 20:20:12.446 DEBUG 21154 --- [nio-8080-exec-2] o.s.s.p.JdbcUserDetailsManager : Query returned no results for user ''
2019-05-25 20:20:12.450 DEBUG 21154 --- [nio-8080-exec-2] o.s.s.a.dao.DaoAuthenticationProvider : User '' not found
org.springframework.security.authentication.BadCredentialsException: Bad credentials.formLogin()
.loginPage("/login")
.usernameParameter("name")
.passwordParameter("password")
<div sec:authorize="isAnonymous()">
<!-- login button here for non logged-in users -->
</div>if(
SecurityContextHolder.getContext().getAuthentication() != null &&
SecurityContextHolder.getContext().getAuthentication().isAuthenticated() &&
!(SecurityContextHolder.getContext().getAuthentication() instanceof AnonymousAuthenticationToken)
) {
return "redirect:/home";
} resources/static/img/myImage.jpg )<img th:src="@{img/myImage.jpg}" alt=""/>localhost:8080/contextPathth:href="@{/url/url}" )public interface UserRepo extends CrudRepository<ClientOrder, Integer> {
}public class ClientOrder {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
@Column(name = "id", nullable = false)
private Long id;public interface UserRepo extends CrudRepository<ClientOrder, Long>ClientOrder() {}public String savePerson(Model model,
@ModelAttribute("personForm") ClientOrder personForm) {firstName != null && firstName.length() > 0firstName != null && !firstName.isEmpty()ApplicationContext представляет собой Spring IoC контейнер и необходим для инициализации, настройки и сборки бинов для построения приложения.
Model, model.addAttribute() th:each
С бд проблема тк у меня MAC OS ,
@Service & @Repository@Query(SELECT House h FROM ... WHERE h.housId = ?1 AND h.housedoc.docType = ?2)
House findHouseByIdAndHouseDocByDocType(Long houseId, int docType)@Entity
Car {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private String carModel;
private String carName;
public Car() {}
//getters & setters & no args constructor
}<form method="post" th:action="@{/cars/add}">
<input type="text" name="carModel">
<input type="text" name="carName">
<input type="submit" value="Добавить машину">
</form>@Autowired
private CarRepository carRepository
@PostMapping("/cars/add")
public String addNewCar(
@ModelAttribute("carModel") String carModel,
@ModelAttribute("carName") String carName,
Car car
) {
// тут конечно можно в carService создать метод и передать ему эти аргументы
car.setCarModel(carModel);
car.setCarName(carName);
carRepository.save(car);
return "main";
}@Column(name = "user_name")
@Getter
@Setter
private String userName;List<Task> tasks), ManyToOne добавьте в Task (User user) и все. localhost:8080/greening то с учетом context path на удаленке будет выглядеть примерно, так localhost:8080/pathfinderPrj_war_exploded/greetingserver.servlet.context-path=/YoutContextPathHerehref="/greeting"используйте его синтаксис th:href="@{/greeting}"