2021-02-22

Using: How to add local jar files to a Maven project?


Firstly, I would like to give credit for this answer to an anonymous Stack Overflow user - I am pretty sure I've seen a similar answer here before - but now I cannot find it.

The best option for having local JAR files as a dependency is to create a local Maven repository. Such a repository is nothing more than a proper directory structure with pom files in it.

For my example: I have my master project on ${master_project} location and subproject1 is on ${master_project}/${subproject1}.

Then I create a Maven repository in: ${master_project}/local-maven-repo.

In the pom file in subproject1 located at ${master_project}/${subproject1}/pom.xml, the repository needs to be specified which would take file path as a URL parameter:

<repositories>
    <repository>
        <id>local-maven-repo</id>
        <url>file:///${project.parent.basedir}/local-maven-repo</url>
    </repository>
</repositories>

The dependency can be specified as for any other repository. This makes your pom repository independent. For instance, once the desired JAR is available in Maven central, you just need to delete it from your local repo and it will be pulled from the default repo.

    <dependency>
        <groupId>org.apache.felix</groupId>
        <artifactId>org.apache.felix.servicebinder</artifactId>
        <version>0.9.0-SNAPSHOT</version>
    </dependency>

The last but not least thing to do is to add the JAR file to local repository using -DlocalRepositoryPath switch like so:

mvn org.apache.maven.plugins:maven-install-plugin:2.5.2:install-file  \
    -Dfile=/some/path/on/my/local/filesystem/felix/servicebinder/target/org.apache.felix.servicebinder-0.9.0-SNAPSHOT.jar \
    -DgroupId=org.apache.felix -DartifactId=org.apache.felix.servicebinder \
    -Dversion=0.9.0-SNAPSHOT -Dpackaging=jar \
    -DlocalRepositoryPath=${master_project}/local-maven-repo

Once the JAR file is installed, your Maven repo can be committed to a code repository, and the whole set-up is system independent. (Working example in GitHub).

I agree that having JARs committed to source code repo is not a good practice, but in real life, quick and dirty solutions are sometimes better than a full blown Nexus repo to host one JAR that you cannot publish.







20210409_am111914

Missing Artifacts

  1. After added repository in pom.xml

  2. After maven install by mvn script.



mvn script: 

mvn org.apache.maven.plugins:maven-install-plugin:2.5.2:install-file  \

-Dfile=/some/path/on/my/local/filesystem/felix.servicebinder-0.9-SNAPSHOT.jar \

-DgroupId=org.apache.felix -DartifactId=org.apache.felix.servicebinder \

-Dversion=0.9.0-SNAPSHOT -Dpackaging=jar \

-DlocalRepositoryPath=${master_project}/local-maven-repo

mvn install:install-file \

   -Dfile=<path-to-file> \

   -DgroupId=<group-id> \

   -DartifactId=<artifact-id> \

   -Dversion=<version> \

   -Dpackaging=<packaging> \

   -DgeneratePom=true




Might need to check if path separator issue:


from: /

<repositories>

<repository>

<id>EmbededMavenRepositories</id>

<url>file://${project.basedir}/src/main/resources/embeded_maven_repositories/</url>

</repository>

</repositories>



to: \



<repositories>

<repository>

<id>EmbededMavenRepositories</id>

<url>file://${project.basedir}\src\main\resources\embeded_maven_repositories\</url>

</repository>

</repositories>



Found it will copy the embedded maven repositories to your user/.m2 folder.






















2021-02-15

Prolink Bluetooth Mouse

 





On: 20210215_pm103652
Suspect Windows updates causing mouse become weird.
Bluetooth Mouse not moving suddenly.
after turn off and on back power at Mouse, red light off after awhile.
Windows 10 doesn't seems able to found any new device too. at this moment, touch pad still unable to be use ( configured disable touch pad after Bluetooth Mouse connected.)
After remove Bluetooth Mouse from devices, then touch pad can be, but Bluetooth still not working at Microsoft Windows 10


Restart 3rd time only bring back this bluetooth on button in Bluetooth & other devices.





Another restart, Bluetooth driver I deleted is back.















Found below:


https://answers.microsoft.com/en-us/windows/forum/windows_10-hardware/after-windows-10-1511-november-update-a-bluetooth/870e9552-a1bf-49a0-99da-736a12d50e92


I managed to solve this myself by installing the "Generic Bluetooth adapter" driver.  

  1. Go to device manager and open Bluetooth
  2. Select the Bluetooth adapter. In my case , my Dell XPS L502X came with "Intel(R) Centrino(R) Wireless Bluetooth(R) 3.0+ High Speed Adapter" driver. Uninstall this default driver.
  3. Scan for hardware changes. You see a unknown device, inside Other
  4. Install a driver for this. While installling choose "Let me choose the best driver"
  5. In the driver choice, I get the "Generic Bluetooth adapter" and the intel one.
  6. Choose "Generic Bluetooth adapter" and install that
  7. Viola, my mouse reconnects without any issues now. No problem with the Bluetooth speaker either 

Image

Image





















2021-01-16

【9个有钱人不想让你知道的秘密 | 富人会做而穷人不会做的事】

 

  1. 有钱人投资自己,穷人投资有钱人。
    有钱人 获得第一笔资金,先会把钱优先投资在 扩大自己的现有业务,从而获取更多的利润后、再用剩下的钱享受生活。
    穷人获得了一笔资金(工资),会迫不及待的消费掉(购买最新的手机),结果没剩下多少钱投资自己,更少的紧急备用金。
  2. 一个人是否有钱,看身边的朋友就知道。
    物以类聚,人以群分。
    自己常来往的 5 个 朋友,有 不好的经济状况。
    经常陷入不良经济状况的人,往往在 开源 和 节流上,做得不够好。
    简言之,就是这个人的金钱观 和 理财观 还有待改进。
    常常 和 这类人 相聚,难免会沾染。
  3. 学历并不代表一切。
    什么学位,都不能证明/代表理财能力。
    一个人的金钱观,是和学校无关。
    学校主要的功能,是为我们的社会培养更多的劳动力。
    假如仅通过学习就能成为 那 20% 的少数人,那现在从大学毕业的人那么多,早就把世界上的财富瓜分殆尽了。
    既然成功只属于少数人,那么学校所提供的大众化教育,就注定没办法满足所有人,实现财务自由的梦想。
    想要脱颖而出,就要终身学习,找到共同成长的小圈子。
    多多参加理财、商务相关的讲座论坛。
    多和拥有正向金钱观的成功者交谈。
    也可以多多关注一些理财、金融教育相关的博客专栏。
  4. 谁都可以成为下个百万富翁。
    成功的关键是你有多渴望成功,并且愿意为之付出多少努力。
    心态决定方向,行动决定你能在这个方向,走多远。
  5. 金钱不是万能的,时间才是。
    合理利用每分每秒。
    时间可以转换成,任何他们所需要的。
    你需要知识,那么就花时间学习吧。
    你需要良好的人际关系,那么就花时间去相处吧。
    你要想源源不断的复利和分红,那么就趁现在,趁时间还早,赶快做投资吧。
    只要你合理的利用时间,时间就可以帮助你实现梦想。
  6. 被让 明天 无限延期你的梦想。
    等毕业,我就开始创业。
    等公司给我涨薪了,我就去投资。
    等孩子长大了,我就能做我想做的一切。
    时机未到,永远是拖延症患者的最佳借口。
    一个人的梦想不在大,从小处做起,积少成多。
    终有一天,一个个的小成就,会串连成巨大的成功。
  7. 有钱人都有 7 个 收入来源。
    65% 的富人在赚到第一桶金之前,至少都有 3 个收入来源。
    平均而言,百万富翁会将家庭年收入的 20% 由于投资。
    无论收入多少,都可以先按比例开始投资。
  8. 打工仔永远都不会成为有钱人。
    别忘了,定义一个人是否富有,可不是简单看一个人的工资;因为一旦停止工作,那么百万年薪不过是一场空。
    简单的从现金流来看,打工者的现金流,流入的是工资;流出的是各项花销和债务:没有工资流入,一切就断了来源。

    而富人的现金流,流出情况跟打工者可能差不太多,但流入的有租赁收入Zūlìn shōurù、分红、利息、版税、等等等等。
    大部分的 流入资金都不是需要 朝九晚五工作的。

    正真判断一个人是否有钱,要看这个人拥有的资产:海外资产、房产、车产、保险、股票、基金、黄金等到。

    按照这个标准,打工者离有钱真的是太遥远了。
  9. 成功没有捷径。
    需要做好为之付出努力的决心。
    人与人的差别,就在有人只动了动嘴、而有的人却真正的付诸 (zhu) 了实践。























Prolink Mouse PMB8502

 

1st Replaced Battery AA on 20210116_pm044022
Used provided battery... forget to get time stamp.









2021-01-11

Solved for my case.

 


Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean defined in @EnableJpaRepositories declared on Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Not a managed type: class java.lang.Object



Replace interface by remove <User>


@Repository
public interface RepoUser<User> extends JpaRepository<User, UserID> {



@Repository
public interface RepoUser extends JpaRepository<User, UserID> {






Solved: Caused by: java.lang.IllegalArgumentException: Not a managed type

Try adding All the following, In my application it is working fine with tomcat

 @EnableJpaRepositories("my.package.base.*")
 @ComponentScan(basePackages = { "my.package.base.*" })
 @EntityScan("my.package.base.*")   

I am using spring boot, and when i am using embedded tomcat it was working fine with out @EntityScan("my.package.base.*") but when I tried to deploy the app to an external tomcat I got not a managed type error for my entity.

 

 

.








Google Referrals