want to translate the Chinese to pinyin。So I want to use the rack(pinyin4j.jar).But the maven dependency tree do not contain "pinyin4j".
I have try to use zhe command "mvn clean、mvn compile 、mvn install 、mvn reimport"
I have try to delete it and add it again.
import net.sourceforge.pinyin4j.PinyinHelper;
this does not work.
Try following steps, It is working fine in my system:
Go to the location of your project.
Example: D:\Project\workspace\com.test.pinyin4j>
Try mvn clean install.
Update project and it should work fine.
You can check below attached images. It got successfully imported.
Note: Don't forget to add pinyin4j dependency in POX file.
<dependencies>
<!-- https://mvnrepository.com/artifact/com.belerweb/pinyin4j -->
<dependency>
<groupId>com.belerweb</groupId>
<artifactId>pinyin4j</artifactId>
<version>2.5.0</version>
</dependency>
</dependencies>
Related
I want to use AWS S3 buckets with my Java 17 / Maven 3.8.5 app but when I add this to the pom.xml file
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk</artifactId>
<version>1.12.177</version>
</dependency>
I get a bunch of errors like these:
Failed to read artifact descriptor for com.amazonaws:aws-java-sdk-iotevents:jar:1.12.177
although when I add -core like this:
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-core</artifactId>
<version>1.12.177</version>
</dependency>
the errors go away in my pom.xml file but I dont think this is what I want.
What I want is to be able to import com.amazonaws.services.s3.AmazonS3; like this
import com.amazonaws.services.s3.AmazonS3;
import org.springframework.context.annotation.Configuration;
#Configuration
public class AmazonConfig {
public AmazonS3 s3() {
AWSCredentials awsCredentials = new BasicAWSCredentials("", "");
}
}
but I keep getting this error
The import com.amazonaws.services.s3 cannot be resolved
Im really new to Java so I'm not sure if the problem is from my Maven configuration or something else.
Thanks.
you may need to do a mvn install or mvn package, this way, you will download the dependency.
First of all check if the dependencies are pulled or not in the external dependencies section in the IDE. If its not there see if maven is configured properly.
What ide are you using?
If its eclipse force a maven update on the project. If it’s Intellij, invalidate caches from the file menu. Close the ide. Open the root directory of you project in file explorer and Delete any .preferences or .setting or any other unnecessary file or folder present on the source folder reated by the ide and after clearing all that open up IDE and see if that resolves the issue.
Also for s3 you’ll need this dependency
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-s3</artifactId></dependency>
Really not sure what was wrong but restarting a new project worked.
Pls are there any Java libraries that can retrieve Maven dependencies from a POM file? Anything that does not require retrieving out put of a mvn command. Thanks
Well, you should parse the pom.xml with any xml parser of your choice.
Then construct the link to maven central repository by the following algorithm:
1. Each package in group id is translated to a folder:
Example:
<groupId>org.foo.bar</groupId> ==> org/foo/bar
Artifact name is also a folder and append it to the group id:
Example:
<artifactId>some-artifact</artifactId> ==> org/foo/bar/some-artifact
Version also becomes folder:
Example:
<version>1.2.3</version> ==> org/foo/bar/some-artifact/1.2.3
Now construct the jar name as "articatId-version.jar" and append it to the link.
Prepend the repository and you'll get a full-working path.
Here is a real working example:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot</artifactId>
<version>2.2.4.RELEASE</version>
</dependency>
Gets translated to:
https://repo1.maven.org/maven2/org/springframework/boot/spring-boot/2.2.4.RELEASE/spring-boot-2.2.4.RELEASE.jar
As an alternative if you want some library that can work with dependencies don't want to call maven, take a look at Apache Ivy
Thanks.
I used the MavenProject library. Pretty straight forward.
I also used MavenXppReader to get the model that I passed to MavenProject(). The rest was a matter of calling the right methods.
I have been doing my project and all the sudden eclipse started to give this error saying
The type com.google.protobuf.GeneratedMessageV3$Builder cannot be resolved.
It is indirectly referenced from required .class files where we declare the package. I have tried adding com.google.protobuf-2.4.0.jar to build path but it did not work. Please help and here's the screenshot.
com.mysql.cj.x.protobuf.MysqlxSql.StmtExecute is not on the classpath so remove this import
If you are expecting Protobuf generated files to be available, then ensure that you have added the Protobuf library to your project.
Gradle example:
implementation group: 'com.google.protobuf', name: 'protobuf-java', version: googleProtobufVersion
Maven example:
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
<version>${googleProtobufVersion}</version>
</dependency>
Not sure if this helps at such a later date. But i also faced something similar.
I found that I imported this by mistake
import com.mysql.cj.x.protobuf.MysqlxDatatypes.Array;
After removing this line, it works fine.
In your case you need to remove the import
com.mysql.cj.x.protobuf.MysqlxSql.StmtExecute
Replace it with the relevant import.
This is due to the missing dependency of gRPC protobuf. Add this dependency to your pom.xml and this should solve your problem.
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-protobuf</artifactId>
<version>1.16.1</version>
</dependency>
Lastly, do maven -> project update
I created a "lib" folder in my project
~\test2000\lib\ls-client.jar
Then, I added a jar file to this folder
Now I want to call him in the project, I did this with the following code, In my system right.
<dependency>
<groupId>com.lightstreamer</groupId>
<artifactId>ls-client</artifactId>
<version>2.5.2</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/ls-client.jar</systemPath>
</dependency>
But when I transfer the program to the Linux server
There's an error saying that it can not read jarFile
I think I do not enter groupId and artifactId!!!
Can anyone help me?
step 1:
Download the "ls-client", extract it and copy the ls-client.jar to somewhere else, for example, c drive. Issue following command :
mvn install:install-file -Dfile=c:\\test2000\lib\ls-client.jar -DgroupId=com.lightstreamer
-DartifactId=ls-client -Dversion=2.5.2 -Dpackaging=jar
step 2:
<dependency>
<groupId>com.lightstreamer</groupId>
<artifactId>ls-client</artifactId>
<version>2.5.2</version>
</dependency>
I'm new to Maven and the AWS SDK. So I installed both and updated my Java SDK. Double checked all required path and classpath settings.
The AWS Polly manual (page 119 in the pdf) presents a demo code example, to test Polly.
Being in this for the very first time, I tried this example (pom.xml and PollyDemo.java). Calling Maven as written in the manual, I receive the ClassNotFoundException for PollyDemo (classpath to com.amazonaws.demos.polly package has been set).
With over 10 years Java experience I feel like a newbie.
Please help
you need to add aws-java-sdk-polly dependency into your pom.xml
file and update the project, you can find dependency below:
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-polly</artifactId>
<version>1.11.77</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.googlecode.soundlibs/jlayer -->
<dependency>
<groupId>com.googlecode.soundlibs</groupId>
<artifactId>jlayer</artifactId>
<version>1.0.1-1</version>
</dependency>
for more you can refer below link :
http://docs.aws.amazon.com/de_de/polly/latest/dg/examples-java.html
http://docs.aws.amazon.com/polly/latest/dg/examples-java.html
The example can be run if: AWS credentials are created and setted (1), a new project is started by creating an empty directory (e.g. 'my-app'),
opening a shell in 'my-app' and running the command 'mvn archetype:generate -DgroupId=com.amazonaws.demos.polly -DartifactId=polly-java-demo -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false' (2), and finally replace both the existing 'pom.xml' and hello world java file with the ones in the example (3).