我从 spring data jpa 开始,我已经配置了所有 spring 应用程序。其中我的 Bootstrap 类是
@SpringBootApplication
@ComponentScan("com.ticket.booking")
@EnableJpaRepositories("com.ticket.booking.dao")
@EntityScan("com.ticket.booking.entity")
public class TicketBookingManagementApplication {
public static void main(String[] args) {
SpringApplication.run(TicketBookingManagementApplication.class, args);
}
我的 Controller
@RestController
@RequestMapping(value="/api/ticket")
public class TicketController {
@Autowired
private TicketService ticketService;
@GetMapping(value="/")
public String welcome(){
return "Welcome to Ticket Booking Systems";
}
@PostMapping(value="/add")
public Ticket createTicket(@RequestBody Ticket ticket){
return ticketService.createNewTicket(ticket);
}
@GetMapping(value="/get/{ticketId}")
public Ticket getTicket(@PathVariable ("ticketId") Integer ticketId){
return ticketService.getTicketById(ticketId);
}
服务和存储库
@Service
public class TicketService {
@Autowired
private TicketDao ticketDao;
public Ticket createNewTicket(Ticket ticket) {
// TODO Auto-generated method stub
return ticketDao.save(ticket);
}
public Ticket getTicketById(Integer ticketId) {
// TODO Auto-generated method stub
return ticketDao.findOne(ticketId);
}
}
public interface TicketDao extends CrudRepository<Ticket, Integer>{}
在 pom.xml 中我添加了
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
它使用 mysql-connector-java-5.1.46.jar:5.1.46
并成功映射 req 但在运行应用程序时出现类似
java.sql.SQLException: Unknown system variable 'language'
并将模式导出到数据库
最佳答案
更新您的 mysql-connector 版本。它将解决您的问题。
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.35</version>
属性:
spring.datasource.url=jdbc:mysql://localhost/schema_name
spring.datasource.username=root
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.jpa.database-platform=org.hibernate.dialect.MySQL5InnoDBDialect
关于mysql - 获取 : java. sql.SQLException:未知系统变量 'language' spring boot,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51470996/