【发布时间】:2018-07-23 02:41:31
【问题描述】:
我从 spring data jpa 开始,我已经配置了所有 spring 应用程序。我的引导类是
@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);
}
}
我的控制器
@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版本
-
mysql 版本 5.1.30
-
能否提供mysql的详细配置信息
-
提供有问题的配置属性
-
@Vishal Kawade 立即查看
标签: mysql spring-boot spring-data-jpa