I want to use MySQL using reflection, but have had to hard code the MySQL jar file – can I download latest version from Maven?

huangapple go评论94阅读模式
英文:

I want to use MySQL using reflection, but have had to hard code the MySQL jar file - can I download latest version from Maven?

问题

我有一个通用的工具jar文件,用来访问MySQL。当我查看这个jar文件时,我发现它大约有11兆字节,其中包括了MySQL和ProtoBuf,而我自己的代码只有大约0.5兆字节。MySQL仅被我的一些工具所使用,因此我想要下载MySQL的相关内容,并且对于MySQL的函数使用反射(reflection)。

目前反射的代码已经在运行中,但是MySQL jar文件的位置和版本号必须硬编码在代码中。这也依赖于Eclipse(.m2)。我想要做的是总是下载最新版本的MySQL并使用它。我认为我可以使用Maven的函数来下载最新的版本,但我不确定接下来该怎么做!有人建议使用Aether - 它还活跃吗?

提前致谢。

英文:

I have a general tools jar file which access MySQL. When I looked at the jar file, I saw it had about 11 Mb comprising MySQL and ProtoBuf, while my own code is about .5 Mb. The MySQL is only used by a couple of my tools, so I would like to download the MySQL stuff, and use reflection for the MySQL functions.

The reflection code is now working, but the MySQL jar file location and version number has to be hard-coded. It is also Eclipse-dependent (.m2). What I would like to do is always download the latest version of MySQL, and use that. I think I can use Maven functions to download the latest version number, but I'm not sure where to go from there! Someone suggested Aether - is that still active?

TIA

答案1

得分: 0

我认为你可以只使用最新版本的快照。据我所知,如果你使用-SNAPSHOT,Maven会每天搜索新版本。

英文:

I think you could just use a snapshot of the latest version. As far as I know, Maven searches for new versions on a daily basis if you use -SNAPSHOT.

答案2

得分: 0

我有一个使用Curl的工作解决方案,可以两次访问Maven中的信息:第一次是为了找出mysql-connector-java(jar文件)的最新版本,第二次是为了下载它。这个方法是有效的,但我同意@Taylor的观点,并且会尝试提出一个非反射性的解决方案。不过,我将会关闭这个问题。

英文:

I have a working solution using Curl to acess information from Maven - twice: once to figure out the latest version of mysql-connector-java (the jar file), and one to download it. It works, but I agree with @Taylor 's point, and will see if I can come up with a non-reflection solution. I will however close this question.

huangapple
  • 本文由 发表于 2020年10月20日 03:43:55
  • 转载请务必保留本文链接:https://go.coder-hub.com/64434180.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定