我从spring数据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'
并将架构导出到数据库
答案 0 :(得分:1)
更新您的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
答案 1 :(得分:0)
我发布此答案是因为有人可能会从中受益。
就我而言,我正在使用Spring-boot,因此pom.xml中的依赖项为
df['conditional_sum'] = result
df.to_csv('file.csv')
因此Spring Boot从Spring Boot父级那里获取了一些默认的依赖版本,这与我的系统安装的mysql-server版本5.1.22不同,所以这就是该错误的原因。
因此,要解决此错误,我通过如下手动指定覆盖了版本。
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
它奏效了。