Sebenzisa indlela ephambili yeJava eMaven

Ibhlog

Sebenzisa indlela ephambili yeJava eMaven

1. Amagqabantshintshi

Kule tutorial imfutshane, siza kubona indlela yokuqhuba ngokungahambelaniyo iindlela eziphambili nakweyiphi na iklasi yeJava isebenzisa iMaven.

2. Inkqubo yenza-maven-iplagi

Masicinge ukuba sineklasi elandelayo:

ungayikhupha njani imali kwi-wallet ye-trust ukuya kwi-akhawunti yebhanki
public class Exec { private static final Logger LOGGER = LoggerFactory.getLogger(Exec.class); public static void main(String[] args) { LOGGER.info('Running the main method'); if (args.length > 0) { LOGGER.info('List of arguments: {}', Arrays.toString(args)); } }}

Kwaye sifuna ukwenza eyona ndlela iphambili ukusuka kwilayini yomyalelo ngeMaven.

Ukwenza oku, sinokusebenzisa i- yenza-maven-iplagi . Ukucacisa ngakumbi, i _exec: Java _ njongo ** Ukusuka kule iplagi iphumeza udidi lweJava olunikezelweyo kunye nokuxhomekeka kweprojekthi njengeendlela zeklasi. **

Ukwenza eyona ndlela iphambili ye- Ukuqhutywa iklasi, kufuneka sidlulise igama elifanelekileyo leklasi kwi-plugin:

$ mvn compile exec:java -Dexec.main02:26:45.112 INFO com.baeldung.main.Exec - Running the main method

Njengoko kubonisiwe apha ngasentla, sisebenzisa _exec.mainClass _system ipropathi ukugqithisa igama leklasi elifanelekileyo ngokupheleleyo.

Kwakhona, kufuneka siqiniseke ukuba indlela yeklasi ilungile ngaphambi kokusebenzisa eyona ndlela. Kungenxa yoko le nto sihlanganisa ikhowudi yemithombo ngaphambi kokwenza eyona ndlela iphambili.

Singafezekisa into enye ngokucacileyo _java _and _javac. _Nangona kunjalo, oku kunokuba nzima xa sisebenza ngendledlana enkulu yeklasi. Okuphikisanayo, xa usebenzisa le iplagi, Maven ngokuzenzekelayo ukhathalela ukugcwala kwendlela yeklasi.

#ijava #maven

Ulwalamano lomntu omnye kunye no-django

feedproxy.google.com

Sebenzisa indlela ephambili yeJava eMaven

Funda ukuba usebenzisa indlela ephambili yeJava usebenzisa iMaven. Kwesi sifundo sifutshane, siza kubona indlela yokuqhuba ngokungahambelani neendlela eziphambili kulo naluphi na udidi lweJava usebenzisa iMaven.